Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: Dyndrilliac on February 19, 2004, 08:24 AM

Title: Help with a summing program.
Post by: Dyndrilliac on February 19, 2004, 08:24 AM
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?
Title: Re:Help with a summing program.
Post by: Moonshine on February 19, 2004, 10:55 AM
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