Understanding Output.

I am reviewing for a test and have a very simple question that I can't seem to wrap my mind around. Why does the following code only output "Ready." I've plugged in other values for "e" that should make other outputs occur but it always kicks back "Ready." I just dont understand what the program is doing here. Any explanation would greatly help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 //Test.cpp


# include <iostream>
using namespace std;

int main()
{
	int e(8);
	int f(18);
	double g(3.2);

	if (6 < e <= 7) {
		cout << "Ready" << endl;
	}
	else if (9 < f < (e * g)){
		cout << "Set" << endl;
	}
	else cout << "Go" << endl;

	return 0;
}
I'm fairly certain that the comparing operators (<,>,==,etc) only take 2 arguments; the value to the left and the value to the right. I don't think that it understands the expressions in the way you understand them.

In other words, try
1
2
if((6<e)&&(e<=7){...}
else if((9<f)&&(f<(e*g))){...}


Again, not sure about my explanation, but I am 100% sure that my solution will solve the problem.
Relational operators take two operands and return a boolean. Their grouping is from left to right.
1
2
3
6 < 8 <= 7
// equals
(6 < 8) <= 7
Thank you! This makes sense now, was reviewing off an old test and I think this was a trick question the professor put on the test. I really appreciate your help!
Topic archived. No new replies allowed.