Float and double in c/c++

main()
{
float me=1.1;
double you=1.1;
if(me==you)
printf(“same”)
else
printf(“different”);
}
Tutorial answer:
different

Debugging solution:
Because int the floating point numbers cannot be predicted exactly. so if condition become false. and it is depends upon the bytes. Float take 4 bytes long double take 8 bytes

Post a Comment

0 Comments