#WSQ07 – Sum of numbers.

sum-of-consecutive-numbers

Hello people! It’s time of partial exams so I was so bussy studying but here I am with new posts of programming 😀. Well, on this new program we have to ask for a range of integers and then prints the sum of the numbers in that range. For example if we use 9 and 15, the program may do the next addition: 0+9+10+11+12+13+14+15=x. How do we do that?

First, we have to ask for the two numbers to have the range of numbers to make the addition. Then we use a loop (DO-WHILE) to add the following numbers with a counter (++) while the counter be different of the bigger number.

So, here the screenshot of my C++ code.

son

As you can see, the loop do-while help us to make the increase in the lower number until we reach the highest bound.

And the program running:

songggg.png

Dont forget to see my codes on GitHub, click here to see them.

CC BY-SA 4.0 #WSQ07 – Sum of numbers. by eduardomoralesg is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.