0

unary operators : If float x; then x=sizeof(double) then why out is 0

29th Mar 2020, 3:33 PM
Ankit Patil
Ankit Patil - avatar
5 Antworten
+ 1
Because you use wrong format specifier. %d is used for `int` data. But you are actually printing `float` data. Use %f instead of %d, and it will work 👍
29th Mar 2020, 8:08 PM
Ipang
+ 2
Thanks you for helping me 👍👍👍
29th Mar 2020, 8:11 PM
Ankit Patil
Ankit Patil - avatar
+ 1
No problem buddy 👌 And for further introduction on format specifiers, you can check these out 👇 http://www.cplusplus.com/reference/cstdio/scanf/ http://www.cplusplus.com/reference/cstdio/printf/
29th Mar 2020, 8:15 PM
Ipang
0
Why out is 0? I don't know. In your code you don't seem to be printing anything out. But assuming you did print the <x> value, how did you do it?
29th Mar 2020, 4:47 PM
Ipang
0
#include<stdio.h> Main() { float x; Clrscr(); X=sizeof (double); Printf(''%d",x); getch(); } This is the program Why output is 0 when float contain 4 byte and double contain 8 byte
29th Mar 2020, 6:05 PM
Ankit Patil
Ankit Patil - avatar