write a program that performs an arithmetic sequence summation (arithmetic series).

C Programming Language / Operators and Enums in C Language

2284

Program:

#include<stdio.h> 
int main(){

float n, a1, an, d;
float sn;


printf("Enter how many term: ");
scanf("%f",&n);
printf("Enter first term: ");
scanf("%f",&a1);
printf("Enter last term: ");
scanf("%f",&an);
 

sn = (n*(a1+an))/2;

printf("summation: %f \n", sn);

}

Output:

Enter how many term: 41
Enter first term: 1
Enter last term: 101
summation: 2091.000000
Press any key to continue . . .

Explanation:

n -Total Term

a1 - is first term

an - is last term

d -Common difference

Formula for calculating sum of n terms in arithmetic sequence summation (arithmetis series)

sn = (n*(a1+an))/2;

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.