numbers1

Image Source: http://www.leehazard.com/the-numbers-game/

Hello everyone! Today, not the same today of the last post, I created a program which calculated the sum of a range of integers with given bounds. This was pretty simple since it only consisted of using while or for loops for doing repetitions. The idea of giving the wrong bounds intrigued me since a code that assumed the bounds were right would make an infinite sum and return an error. So I turned the sum into a funtion so it would be easier to change the bounds, added an if so it could inform the user his input was wrong and return a result with changed bounds. I found this page with a nice explanation about loops:

http://www.cprogramming.com/tutorial/lesson3.html

And here’s the code in GitHub: 

https://github.com/CarlosGallegosT/Codes007/blob/master/Sum%20of%20Numbers

Thanks for watching!

 

 

CC BY 4.0 Sum of Numbers #WSQ07 by Carlos Gallegos is licensed under a Creative Commons Attribution 4.0 International License.