double greater than

I'm having a problem using a double greater than comparison. The code is suppose to validate true to my understanding but does not. Can any one help.

int j = 105, i = 101, k = 99;

if ( j > i > k)
cout << " j > i > k === true" ;
else
cout << "j > i > k === false";
The IF condition has to compare J and I separately and I and K. So if you change it to.

1
2
3
4
5
6
int j = 105, i = 101, k = 99;

if ( j > i && i > k)
cout << " j > i > k === true" ;
else
cout << "j > i > k === false";


This should fix your problem.
a > b > c means something completely different from what you'd expect. You have to write it as a > b && b > c.
Also, === is not a legal operator.
closed account (DEUX92yv)
Use if (j > i && i > k).
Relational operators (such as less-than and greater-than) return a bool. Your code tries to check if a bool is greater than an int.
Topic archived. No new replies allowed.