• Welcome to Valhalla Legends Archive.
 

Help with a summing program.

Started by Dyndrilliac, February 19, 2004, 08:24 AM

Previous topic - Next topic

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?
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Moonshine

#1
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