C - Keywords - Discussion

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

 



Q.

What will be output when you will execute following c code?

#include
int main()
{
double num=5.2;
int var=5;
printf("%d\t",sizeof(!num));
printf("%d\t",sizeof(var=15/2));
printf("%d",var);
return 0;
}
Choose all that apply:

A. 7 B. 8
C. 7.0 D. 6

Answer: Option B
Explaination:

 


This is because 7.0 is treated as double (double precision) and not as float (single precision). To make it float, write it as 7.0f.



Discussion

Your Comments Goes here...
NameDiscussion