# Sumation Help

This is a discussion on Sumation Help within the C Programming forums, part of the General Programming Boards category; I have this assingment: Write a C program that prompts the user to input the values of a0, an, and ...

1. ## Sumation Help

I have this assingment:
Write a C program that prompts the user to input the values of a0, an, and d, computes the value of the sum of the series and then displays the result. If the user inputs 1 for a0, 11 for an, and 2 for d, a typical output would look like:

Sum(1,11,2)=36

This is the Code that I put together but it doesn't work could someone out there help me out?? =) Thanks

Code:
```#include <stdio.h>

int main(void)
{
int A0, An, d, sum, x;
printf("Enter A0, An, d : \n");
scanf("%d %d %d",&A0,&An,&d);
x=A0;
sum=0;
for(x=A0;x<=An;x+=d)
sum+=d;
printf("Sum(%d,%d,%d)=%d\n",A0,An,d,sum);

return 0;
}```

2. You're doing your sum wrong. You're adding d to it, when you should be adding x.

Quzah.

3. So just change sum+=d to sum+=x ??

4. AHH That worked!!! THANKS A BUNCH!!