Explain the output. .....? | SoloLearn: Learn to code for FREE!


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; }

5/16/2020 3:48:55 AM


1 Answer

New Answer


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