I guess it has to do with how float/double is stored on your computer.
Always use an error tolerance when it comes to floating-point numbers
comparison. By the way, on my machine it outputs the same
thing("Hello")
e.g.
#define epsilon 10e-6
if(275.7-a>epsilon)
printf("HI");
else
printf("Hello");
On Jan 8, 9:24 pm, priya mehta <[email protected]> wrote:
> #include<stdio.h>
> int main()
> {
> float a=275.7;
> if(275.7>a)
> printf("Hi");
> else
> printf("Hello");
> return 0;
>
> }
>
> #include<stdio.h>
> int main()
> {
> float a=75.7;
> if(75.7>a)
> printf("Hi");
> else
> printf("Hello");
> return 0;
>
> }
>
> why the above two programs give different output?
--
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.