Question:What will be output when you will execute following c code?#include<stdio.h>
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;
}
+ Explanationsizeof(Expr) operator always returns the an integer value which represents the size of the final value of the expression expr.
Consider on the following expression:
!num
=!5.2
=0
0 is int type integer constant and it size is 2 by in TURBO C 3.0 compiler and 4 in the TURBO C 4.5 and Linux GCC compilers.
Consider on the following expression:
var = 15/2
=> var = 7
=> 7
7 is int type integer constant.
Any expression which is evaluated inside the sizeof operator its scope always will be within the sizeof operator. So value of variable var will remain 5 in the printf statement.