← Back to Loops
Question 394
Largest Until Zero
Largest Until Zero
Read whole numbers one per line until a 0 arrives (the sentinel, which is not a reading). Track the largest value seen with a while loop and print Largest: <value> after the loop; the first reading starts as the largest. If the very first line is 0 print No readings. Input: several lines, each a positive integer, the last one 0, no prompts.
Expected Output:
Largest: 9= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.