64 696
Assignments Done
99,4%
Successfully Done
In September 2018

Answer to Question #45585 in C++ for pramod

Question #45585
main()
{
float a=0.7;
if(0.7>a)
{
cout<<("true");
}
else
{
cout<<("false");
}
}
Question : why the output of this program is true ?
nd when i take the value of a is 0.6 then it is false ??
Expert's answer
Dear visitor,
It happens because you use the float data type. it is&nbsp;known for its imprecision. If you want to have the correct work in such cases, it is better to use double. They are called double precision type for a reason.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions