In this tutorial you will learn about the C Program to Find Sum of Arithmetic Progression Series and its application with practical example.
C Program to Find Sum of Arithmetic Progression Series
In this tutorial, we will learn to create a C program that will Find Sum of Arithmetic Progression Series using C programming.
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- While loop in C Programming.
- Functions in C Programming.
What is Arithmetic Progression?
The arithmetic progression is a series in mathematics that starts from a point and the second term is having a common difference, and this series continues till the endpoint with the common difference.
Programs to Find Sum of Arithmetic Progression Series:-
In this program, First, we take the first term of the arithmetic progression. Then we will take the total number of terms in A.P. At last we will take the common difference from the user. Now we will generate the arithmetic progression using the for loop and the mathematical expressions. Then will print the sum of the arithmetic progression.
/* C Program to find Sum of Arithmetic Progression Series */
//DEclaring the required variables for the program.
int first_term, no, dis, tn, i;
int sum = 0;
//Taking the first term of A.P.
printf(" Please Enter First Number of an A.P Series: ");
//Taking the number of terms in ap
printf(" Please Enter the Total Numbers in this A.P Series: ");
//Taking the Common Difference of ap
printf(" Please Enter the Common Difference: ");
//Creating the Arithmetic Progression.
sum = (no * (2 * first_term + (no - 1) * dis)) / 2;
tn = first_term + (no - 1) * dis;
//Calculating the sum of a.p.
printf("\n The Sum of Series A.P. : ");
for(i = first_term; i <= tn; i = i + dis)
if(i != tn)
printf("%d + ", i);
printf("%d = %d", i, sum);
In the above program, we have first initialized the required variable
- first_term = it will hold the integer value.
- no = it will hold the integer value.
- dis = it will hold the integer value.
- tn = it will hold the integer value.
- i = it will hold the integer value to control the array.
Taking the first term, common distance, and the number of terms from the user.
Generating the A.P. using the loops and calculating the sum.
Program Code for Printing the sum of series.