finding output of C code

coder12's Avatar, Join Date: Sep 2012
Newbie Member
#include<stdio.h>
#include<conio.h>

double i;
void main()
{
(int )(float)(char) i;
printf("%d",sizeof(int )(float)(char) i));
getch();
}

Give required explanation[/B]
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
The only valid explanation of this code is that its author is an idiot.
0
state's Avatar, Join Date: Sep 2011
Go4Expert Member
Hello there coder12
If these are the exact LOC then you will get an error.
"syntax error before '(' token "
Assuming you mistyped,this is a question related to type casting.So what happens is i is casted to char then float and finally to int.As a result you get the o/p -->4(mingw).I don't think the output will vary much if you are using GCC.The gist of the matter is :sizeof(int).Type casts have R to L associativity
Hope this helps