0

What does it mean when the parenthesis after the word "while" contains only a single variable?

You may refer the attached code. https://code.sololearn.com/cZ28BZ3DDb7j/?ref=app

19th May 2020, 7:18 PM
Intan Suraya
Intan Suraya - avatar
6 Réponses
+ 3
Because int x has the truth value true, if x is not 0, and false, if x ==0, you can use an int as a condition.
19th May 2020, 7:22 PM
Jnn
Jnn - avatar
+ 1
Is that means all statements within the while block will be executed only if the values assigned to the variable x is non-zero?
19th May 2020, 7:25 PM
Intan Suraya
Intan Suraya - avatar
+ 1
Yes
19th May 2020, 7:26 PM
Jnn
Jnn - avatar
+ 1
But if x ==2, it is not equal to true but it evaluates to true. https://stackoverflow.com/questions/5189072/c-bool-question
19th May 2020, 7:28 PM
Jnn
Jnn - avatar
0
Understood. Thank you!
19th May 2020, 7:27 PM
Intan Suraya
Intan Suraya - avatar
0
Alright 👍
19th May 2020, 7:31 PM
Intan Suraya
Intan Suraya - avatar