0

why the program reads 16.6<16.5 I have be using codes but every time it consider 16.6<16.5 please help

9th Jul 2016, 4:57 PM
Tushar SHAILY
Tushar SHAILY - avatar
4 Answers
+ 4
If these numbers are stored in variables, the variables must be declared with "float" or "double", since "int" data type cannot assign decimal of fractional values to variables
9th Jul 2016, 6:23 PM
Coder777
+ 4
so in place of int a=16.6 , we have to write float a=16.6
9th Jul 2016, 6:27 PM
Tushar SHAILY
Tushar SHAILY - avatar
0
In order to circumvent such problems in the future, pls read the compilation warnings the compiler produces or if your compiler didn't output any, try to use compiler switches that enable a stricter code checking. This could have been prevented by resolving warnings generated by stricter checks.
9th Jul 2016, 11:45 PM
Stefan
Stefan - avatar
0
if int variables are defined then 16<16 should be falsely read such that user may think it's being read like 16.6<16.5. C++ is very flexible and doesn't produce error easily. that's why it's sometimes difficult to detect the cause of logical error.
24th Jul 2016, 7:21 PM
Adnan Ashraf
Adnan Ashraf - avatar