C - Keywords - Discussion

You Are Here :: Home > C > Keywords - Discussion

 



Q.

What will be output if you will compile and execute the following c code?

#include
int main()
{
int a=5;
float b;
printf("%d",sizeof(++a+b));
printf(" %d",a);
return 0;
}

A. 26 B. 46
C. 25 D. 45

Answer: Option D
Explaination:

 


++a +b

=6 + Garbage floating point number
=Garbage floating point number
//From the rule of automatic type conversion
Hence sizeof operator will return 4 because size of float data type in c is 4 byte. Value of any variable doesn’t modify inside sizeof operator. Hence value of variable a will remain 5.







Discussion

Your Comments Goes here...
NameDiscussion