Sum of numbers: Loops

Write a loop that calculates the sum of the numbers 21, 22, 23, .., 39. The sum is to be
written out after the loop terminates.

I'm stuck on as to how to start this, can someone help me with the base of the loop?
Last edited on
Does the loop start at 21 and end at 39? If so, you could use a for loop that starts are 21 and ends at 39. Just use one variable to increment through the loop and another variable to hold the sum.
Last edited on
Forget the sum. Write a for-loop that prints those numbers.
Topic archived. No new replies allowed.