
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C Program for N-th term of Arithmetic Progression series
Given ‘a’ the First term, ‘d’ the common difference and ‘n’ for the number of terms in a series. The task is to find the nth term of the series.
So, before discussing how to write a program for the problem first we should know what is Arithmetic Progression.
Arithmetic progression or arithmetic sequence is a sequence of number where the difference between the two consecutive terms is same.
Like we have first term i.e a =5, difference 1 and nth term we want to find should be 3. So, the series would be: 5, 6, 7 so the output must be 7.
So, we can say that Arithmetic Progression for nth term will be like −
AP1 = a1 AP2 = a1 + (2-1) * d AP3 = a1 + (3-1) * d ..APn = a1 + (n-1) *
So the formula will be AP = a + (n-1) * d.
Example
Input: a=2, d=1, n=5 Output: 6 Explanation: The series will be: 2, 3, 4, 5, 6 nth term will be 6 Input: a=7, d=2, n=3 Output: 11
Approach we will be using to solve the given problem −
- Take first term A, common difference D, and N the number of series.
- Then calculate nth term by (A + (N - 1) * D)
- Return the Output obtained from the above calculation.
Algorithm
Start Step 1 -> In function int nth_ap(int a, int d, int n) Return (a + (n - 1) * d) Step 2 -> int main() Declare and initialize the inputs a=2, d=1, n=5 Print The result obtained from calling the function nth_ap(a,d,n) Stop
Example
#include <stdio.h> int nth_ap(int a, int d, int n) { // using formula to find the // Nth term t(n) = a(1) + (n-1)*d return (a + (n - 1) * d); } //main function int main() { // starting number int a = 2; // Common difference int d = 1; // N th term to be find int n = 5; printf("The %dth term of AP :%d
", n, nth_ap(a,d,n)); return 0; }
Output
The 5th term of the series is: 6
- Related Articles
- C Program for N-th term of Geometric Progression series
- If eight times the $8^{th}$ term of an arithmetic progression is equal to seventeen times the $7^{th}$ term of the progression, find the $15^{th}$ term of the progression.
- C program to find the sum of arithmetic progression series
- The $m^{th}$ term of an arithmetic progression is $x$ and the $n^{th}$ term is $y$. Then find the sum of the first $( m+n)$ terms.
- JavaScript code to find nth term of a series - Arithmetic Progression (AP)
- Program to find N-th term in the given series in C++
- Program to find N-th term of series a, b, b, c, c, c…in C++
- C++ program to find n-th term of series 2, 10, 30, 68, 130 …
- C++ program to find n-th term of series 3, 9, 21, 41, 71…
- Program to find N-th term of series 3, 6, 18, 24, … in C++
- Python Program for Find sum of Series with the n-th term as n^2 – (n-1)^2
- C++ Program for sum of arithmetic series
- C++ program to find n-th term in the series 7, 15, 32, …
- C++ program to find n-th term in the series 9, 33, 73,129 …
- n-th term of series 1, 17, 98, 354…… in C++

Advertisements