@Ankit: The variable a is a float, while the constant 11.202 is a
double. When the constant 11.202 was rounded to size float in the
assignment, it was (apparently) rounded down. For purposes of the
comparison, a was cast to type double, and the added bits were filled
with zeros. So (double)a compared less than 11.202. Now, if you had
written
if(a<11.202e0)
the output would have been Hello!!! because no casting would have been
involved.
Dave
On Feb 7, 8:52 am, ankit agarwal <[email protected]> wrote:
> #include<stdio.h>
>
> int main()
> {
> float a=11.202;
> if(a<11.202)
> printf("Hiii!!!\n");
> else
> printf("Hello!!!\n");
> return 0;
>
> }
>
> output: Hiii!!!
>
> why does this output comes???
>
> Ankit Agarwal
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.