What's the output?

What is the output of the following C++ code?
My answer was "d" (that is 10) because is my understanding that for a while loop to execute the expresion must evaluate to "true" and in this case the expresion num > 10 is false because num=10.

Please correct me if I'm wrong and again please check if the syntax it's OK

Thanks


num = 10;

while (num > 10)

num = num - 2;

cout << num << endl;

a. 0
b. 6
c. 8
d. 10
I agree with your analysis.
What is the answer?
yes num cannot be greater than ten unless you use this operator >= so your answer is true
Topic archived. No new replies allowed.