cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Sum of numbers: Loops
Sum of numbers: Loops
Nov 14, 2014 at 5:55am UTC
Akigou
(10)
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
Nov 14, 2014 at 5:57am UTC
Nov 14, 2014 at 6:04am UTC
JayhawkZombie
(738)
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
Nov 14, 2014 at 6:11am UTC
Nov 14, 2014 at 6:08am UTC
keskiverto
(10402)
Forget the sum. Write a for-loop that prints those numbers.
Topic archived. No new replies allowed.