## C Program To Calculate Arithmetic Progression

Let’s understand the arithmetic progression series and calculate arithmetic progression in C programming language.

#### What is Arithmetic Progression?

An arithmetic sequence or arithmetic progression is a series of numbers arranged in a way that the difference between any two consecutive terms is constant.

In an arithmetic progression series, every consecutive element has a **Constant difference** between any two terms from the series. This means that the preceding term and the following terms will have the same difference.

In other words, an arithmetic progression is a series in which every next term after the first term is computed by adding the common difference (entered by the user) and preceding term.

Let’s assume that the first term is A and the common difference is D. Therefore, the terms in an arithmetic series will be as follows:

**A, A + 1D, A +2D, A+ 3D**

**The Nth Term will be A + (N – 1)*D**

#### Example For Arithmetic Series

**1 5 9 13 17 21 25**

#### Arithmetic Sequence Formula

**A _{N} = A_{1} + (N – 1)D**

**Note:** This C program for arithmetic progression is compiled with GNU GCC compiler on Linux Ubuntu operating system. However, it is compatible with all other operating systems.

#### Method 1: C Program To Calculate Arithmetic Sequence using For Loop

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <stdio.h> int main() { int counter, limit, common_difference, term; printf("\nEnter Total Number of Terms: \t"); scanf("%d", &limit); printf("\nEnter Common Difference: \t "); scanf("%d", &common_difference); printf("\nArithmetic Sequence From 1 To %d:\n", limit); for(counter = 1; counter <= limit; counter++) { term = 1 + (counter - 1) * common_difference; printf("%d \t", term); } printf("\n\n"); return 0; } |

#### Method 2: C Program To Print Arithmetic Progression using While Loop

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <stdio.h> int main() { int counter = 1, limit, common_difference, term; printf("\nEnter Total Number of Terms: \t"); scanf("%d", &limit); printf("\nEnter Common Difference: \t"); scanf("%d", &common_difference); printf("\nArithmetic Sequence From 1 To %d: \n", limit); while(counter <= limit) { term = 1 + (counter - 1) * common_difference; printf("%d \t", term); counter++; } printf("\n\n"); return 0; } |

#### Output

Let’s discuss more on how to calculate arithmetic progression in C programming in the comment section below if you have any compilation errors and any doubts about the same. For more information on arithmetic sequences, check **Wikipedia**.

Can we make up a program to find arithmetic progression in using Function? It will help me to modularize the program.

Yes! This C Program for Arithmetic progression can be developed using functions. You just need to copy the data within the for loop inside a separate user defined function

Perfect Explanation to Print Arithmetic Progression in C Programming. Thanks.

Nice compilation of both the methods. Its simpler to generate arithmetic progression now!