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
4 odpowiedzi
+ 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
+ 4
so in place of int a=16.6 , we have to write float a=16.6
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.
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.