Valhalla Legends Forums Archive | C/C++ Programming | Help with a summing program.

AuthorMessageTime
Dyndrilliac
I was wondering how I would go about making a console app that outputs the sum of all the numbers between the 2 inputted integers(Starting/Stopping number) - with a simple loop?
February 19, 2004, 2:24 PM
Moonshine
if a & b are the inputted numbers:

int sum = 0;
for (int i = a; i <= b; i++) sum += i;

Edit: You should know how to do that easily, btw. :P
February 19, 2004, 4:55 PM

Search