+ 2
What is the problem with this if-else-if statement?
Soooooo, in my program which determines what grade is whatever number the user inputs, unless the number I input is over 70, it's keep saying that my grade is a B, even though it's not. I being very confused. Here's the code: https://code.sololearn.com/cnfTQlA51aqo/#cpp
3 Respuestas
+ 2
The syntax you use is only possible in python I think...
This: 60 <= grade < 70
is basically the same like:
(60 <= grade )< 70.
Because (60<=grade) is true or false, it will be castet to an int (0 or 1) . But 0 or 1 will be smaller than 70, no matter what you enter. E.g. if you enter 100 you should get A as result, to correct the else if, you should change it to:
60 <= grade && grade < 70
(the other in the same way...)
+ 2
Niwo thx
0
np