← Back to Loops
Question 200
Sum of Even Numbers to 20
Sum of Even Numbers to 20
Write a program that adds up the even numbers 2, 4, 6, and so on up to and including 20, then prints the total. Keep a running sum and use a loop whose counter jumps by two each time so it only ever lands on even values. Print the final total once the loop ends. No input is required.
Expected Output:
110= 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 · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.