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;
}