170,833 views
6 votes
6 votes
Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Test aborted."

User Ooto
by
3.0k points

1 Answer

28 votes
28 votes

Answer:

while ( num >= 0) { ... }

Step-by-step explanation:

Required

Express to execute a while loop with the given condition.

The condition in the question is that: the user input must be greater than or equal to 0.

The statement for this is:


while (
num
>=
0) {
... }

Where num is the input variable

User Sambro
by
2.9k points