More about sizeof()
#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;
return 0;
}
Output:
2 2 5
Explanation:
sizeof(Expr)
operator always returns the an integer value which represents the size of the
final value. Consider on the
following expression: !num
=!5.2
=0
0 is int type integer constant and it size is 2
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.
No comments:
Post a Comment