← Back to Loops
Question 268
Sum From 1 to 100
Sum From 1 to 100
Use a loop to add together every whole number from 1 to 100 (that is, 1 + 2 + 3 + ... + 100) and print the single final total. The trick is to keep a running total in a variable that starts at 0, add the current number to it on every pass of the loop, and then print that total only once, after the loop has completely finished.
Expected Output:
5050= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.