# C Program to Print Arithmetic Progression (AP) Series and Sum till N Terms

• Write a C program to find the sum of arithmetic series till N terms.
• Write a C program to print arithmetic series till N terms.

Arithmetic series is a sequence of terms in which next term is obtained by adding common difference to previous term. Let, tn be the nth term of AP, then (n+1)th term of can be calculated as <br\>(n+1)th = tn + D
where D is the common difference (n+1)th – tn
The formula to calculate Nth term tn = a + (n – 1)d;
where, a is first term of AP and d is the common difference.</br\>

### C program to print arithmetic progression series and it’s sum till N terms

In this program, we first take number of terms, first term and common difference as input from user using scanf function. Then we calculate the arithmetic series using above formula(by adding common difference to previous term) inside a for loop. We keep on adding the current term’s value to sum variable. /*
* C program to print Arithmetic Series and it's sum till Nth term
*/
#include <stdio.h>
#include <stdlib.h>

int main() {
int first, diff, terms, value, sum=0, i;

printf("Enter the number of terms in AP series\n");
scanf("%d", &terms);

printf("Enter first term and common difference of AP series\n");
scanf("%d %d", &first, &diff);

/* print the series and add all elements to sum */
value = first;
printf("AP SERIES\n");
for(i = 0; i < terms; i++) {
printf("%d ", value);
sum += value;
value = value + diff;
}

printf("\nSum of the AP series till %d terms is %d\n", terms, sum);

getch();
return 0;
}

Program Output

Enter the number of terms in AP series
5
Enter first term and common difference of AP series
2 4
AP SERIES
2 6 10 14 18
Sum of the AP series till 5 terms is 50

Try these:

1. A given series could be an arithmetic progression a geometric progression in c++
2. A given series could be an arithmetic progression a geometric progression in c
3. C program to find sum of arithmetic progression
4. C program to find nth term in arithmetic progression
5. An arithmetic progression series of 18 term with common difference d
6. Arithmetic progression in c using for loop
7. Geometric progression program in c
8. Arithmetic progression program in c
9. Arithmetic progression in c skillrack
10. Arithmetic progression in c++ skillrack