I am studying upcoming exams and came across this exam question, which for me does not make sense.
Consider the following main function:
int main()
{
int x = 0;
cout << "x = " << x << ", (0 < x < 10) = " << (0 < x < 10) << endl;
int x = 5;
cout << "x = " << x << ", (0 < x < 10) = " << (0 < x < 10) << endl;
int x = 10;
cout << "x = " << x << ", (0 < x < 10) = " << (0 < x < 10) << endl;
return 0;
}
When the program is executed, the following is printed:
x = 0, (0 < x < 10) = 1
x = 5, (0 < x < 10) = 1
x = 10, (0 < x < 10) = 1
Explain what exactly happened.
This is a question. As far as I know, the last line of output should be "x = 10, (0 <x <10) = 0". What am I missing?
source
share