Monday, December 1, 2008

Operators C Programming Language Question with Explanation

1)what will output ?
void main()
{
float a=0.7;
if(a<0.7)
printf("C");
}
else
{
printf("C++");
}}

output:

explanation :0.7f is float constant. Its binary value
is written in 32 bit.0.7 is double constant(default).
Its binary value is written in 64 bit.0.7L is long
double constant. Its binary value is written in 80 bit.
binary value of
0.7=
(0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011)
now here a is a float variable while 0.7 is double constant .
so a contain only 32 bit value i.e
a=0.1011 0011 0011 0011 0011 0011 0011 0011
while
0.7=0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011
....It is obvious a<0.7>

No comments:

Post a Comment

Thanks to given comments.......

My Blog List