+ 1
Please Help with c++
pls tell me why its not working https://code.sololearn.com/cvddW2wm75jv/#cpp
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.
0
Thanks alot
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).