← Back to Loops
Question 384
Digit Sum
Digit Sum
Read a positive whole number and add up its digits with a while loop: the remainder operator % with 10 peels off the last digit and integer division // by 10 removes it; keep going while the number is above 0. Print Digit sum: <total>. Input: one integer, no prompt.
Expected Output:
Digit sum: 10= 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.