+ 5
How does the sizeof operator works?
Please explain why the output of below code is showing s=4 and x=10? void main{ int x=10, s=0; s=sizeof(x=x+20); cout<<s<<" "<<x; }
2 Answers
+ 1
"x = x + 20" is an expression of type int, so it is 4 bytes. sizeof gets replaced by a constant at compile-time, so the code itself is never executed.