+ 1

Please Help with c++

pls tell me why its not working https://code.sololearn.com/cvddW2wm75jv/#cpp

13th Jan 2022, 6:13 PM
jay
3 Answers
+ 1
it's because the variable c is defined as int, you can't store a float in int. it stores the int part only 36.1 will be 36 without .1 so your input is always false.
13th Jan 2022, 6:31 PM
Bahha┣
Bahha┣ - avatar
0
Thanks alot
13th Jan 2022, 6:34 PM
jay
0
I'm not sure what you mean but here's my correction if it helps #include <iostream> using namespace std; int main() { float a = 36.1; float b = 36.9; float c; cin >> c; if ((c >= a) && (c <= b)) cout << "OK"; else cout << "Not OK"; } c has to be a float and you can use multiple condition if statement for a less complexity using && (and).
13th Jan 2022, 7:38 PM
Heisenberg
Heisenberg - avatar