791 views
1 votes
1 votes

https://gateoverflow.in/118473/gate2017-1-53

https://gateoverflow.in/120912/techtud-c-programming

http://www.iitk.ac.in/esc101/2011Jan/Lectures/lect6.pdf

in case of usigned int and long unsigned mix operation unsigned int promoted to long int or long int promoted to unsigned int

plz provide detailed solution,

according to rule given iitk pdf code block give different output.

1 Answer

4 votes
4 votes

"(char, short) < int < unsigned int < long int < unsigned long int < float < double < long double "

This always works for me. I have checked this at the codeblock. unsigned int get converted in long int.

Here is the code which i have tested. 

int main(){
    unsigned int a = -5;
    long int b = 10;
    cout<<a+b<<endl; // This is giving output 5. It menans unsigned int get converted in long int.
    return 0;
}

Related questions

0 votes
0 votes
0 answers
1
DEBANJAN DAS2k asked Mar 29, 2022
287 views
#include<stdio.h>main(){short int i = 20;char c = 97;printf("%d, %d, %d \n", sizeof(c+1), sizeof(c+1.0), sizeof(c+i));return 0;}What is the output?
2 votes
2 votes
0 answers
2
0 votes
0 votes
0 answers
3
saumya mishra asked May 15, 2018
129 views
1 votes
1 votes
1 answer
4
iarnav asked Apr 18, 2017
655 views
Please kindly tell the full code with the use of sizeof() operator. Thanks!