+ 7

Explain the output. .....?

#include <stdio.h> int main() { float x=0.1; printf("%d%d%d",sizeof(x),sizeof(0.1),sizeof(0.1f)); return 0; }

16th May 2020, 3:48 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
1 Resposta
+ 2
First note: with the current version of SoloLearn compiler, your code does not compile, because sizeof() returns 8 bytes, but %d expects 4 bytes. So replace "%d%d%d" with "%ul%ul%ul" , Second note: the size of a float is 4, the size of a double is 8 Said that, the result is 484 because x is declared float (assignment with a double is automatically casted to float); 0.1 is a constant double; 0.1f is a constant float
16th May 2020, 4:14 AM
Bilbo Baggins
Bilbo Baggins - avatar