+ 5
Seems working fine for me. Did you get the input?
cin >> temp;
+ 4
What is data type for variable <temp>?
+ 3
Sudhanshu Pandey
LOL 😂
Careful with swears bro ...
+ 3
Sudhanshu Pandey Lol😅 Wlcm
+ 3
If it says "not inclusive", use > rather than >=
+ 2
Use double instead,
Floating point literals like 36.1 or 36.9 are `double` type (by default). And comparison of a `float` and a `double` usually doesn't come as expected.
+ 2
#include <iostream>
using namespace std;
int main() {
//your code goes here
float temperature;
cin >> temperature;
if (temperature >= 36.1 && temperature <= 36.9) {
cout << "OK" << endl;
}
else {
cout << "Not OK" << endl;
}
}
+ 1
float temperature;
cin >> temperature;
if (temperature >= 36.1 && temperature <= 36.9)
cout << "OK" << endl;
else
cout << "Not OK" << endl;
0
#include <iostream>
using namespace std;
int main() {
float temp;
cin >> temp;
//your code goes here
if(temp >= 36.1 && temp <= 36.9){
cout << "OK" << endl;
} else {
cout << "Not OK" << endl;
}
}
0
If I use float type, the program gives "Not OK" for the limit values (36.1 and 36.9). However, if I change the data type to double, it gives "ok" as expected. Why is that?
0
This Is Coorct Answer
#include <iostream>
using namespace std;
int main() {
//your code goes here
float temperature;
cin >> temperature;
if (temperature >= 36.1 && temperature <= 36.9) {
cout << "OK" << endl;
}
else {
cout << "Not OK" << endl;
}
}



