May 29, 2013 at 8:45am UTC
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";
May 29, 2013 at 8:59am UTC
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.
May 29, 2013 at 9:01am UTC
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.