CJCoding With Joseph
15free / daySign inCreate account

Sum Until Zero

Read whole numbers one per line and add them up until a 0 is read; the 0 is a sentinel that ends the loop and is not added. Print the sum in the form Sum: <total>. Input: several lines, each an integer, the last one 0, no prompts. Use a while loop whose condition compares the latest value with 0.

Expected Output:

Sum: 18

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
Loops
📥 Auto-Input:
5\n10\n3\n0\n
This input is automatically fed to your program's stdin
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.