Problem with else if in Clion
#include <iostream>
using namespace std;
int main() {
int A, B;
while (true) {
cout << "Unesite broj A: ";
cin >> A;
cout << "Unesite broj B: ";
cin >> B;
if ((A >= 10 || A <= 20) || (B >= 10 || B <= 20 ))
break;
else if ((A >= 50 || A <= 70 ) || (B >= 50 || B <= 70)) {
break;
}
}
This is the code and everything after the second || in the first if condition is greyed out as a comment and I don't understand why. The whole else if condition is greyed out. I'm very new to c++ and I just switched from Dev c++ to Clion. Please help
请先登录再写评论。
Hi!
CLion correctly detects that A >= 10 || A <= 20 condition is always true (in other words, there is no A value where it can't be true), so the rest of the conditions don't matter and won't be executed. Maybe you've meant && instead of ||?