# Absolutely stumped with running sum problem.

This is a discussion on Absolutely stumped with running sum problem. within the C Programming forums, part of the General Programming Boards category; I've been at this for hours, and cant seem to get a grasp on what I should use here. The ...

1. ## Absolutely stumped with running sum problem.

I've been at this for hours, and cant seem to get a grasp on what I should use here. The problem is that I have to add the numbers from 100 counting down, to equal 5005. For example 100+99+98+97 and so on. This problem is probably a lot easier to do than I'm making it out to be.

I tried a do while loop, and several others, but I just dont know which loop to use. Here's my sorry excuse of a program, and if I could just get hints as to what I should use, that'll be appreciated. I want to still try to figure it out, so I'll learn:
Code:
```#include <stdio.h>

int main(void)
{
int sum = 0;
int i = 100;

do
{
sum = sum + i;
i = i - 1;
}
while(sum < 5005);
printf("%d  %d, ", i, sum);

}```
Lol, you can see how stumped I was. XD Its supposed to print "100+99+98,...... equal 5005" listing all the integers counting down from 100.

2. Put your print sum line of code, inside the do while loop.

3. For loop is compatible for this
Try this ,
Code:
```for ( ; sum <= 5005 ; sum =sum+i , i=i-1 )
{
printf("%d  %d, \n", i, sum);

}```

4. Damn, it really WAS simple. XD I basically had the right ideas, just didnt work with the right loop functions. And here I thought I was good at FOR. XD