If condition and float in c/c++

main()
{
float a=.7;
if(a<.7)
printf(“student”);
else
printf(“website”);
}


Tutorial answer:
student
Debugging solution:
Normally you think output is website
Because if condition(a<.7)is not true but not like that

In the float value if variable value is less than 1 mean I will consider the variable as 0.so in these case a is 0.
So if(0<.7)is true so output is website.
float
.1,.2,.3…………. .8,.9 consider as 0.

Post a Comment

0 Comments