Computer Science, asked by shreyansh9300, 25 days ago

Write a program (WAP) that will print following series upto Nth terms

Answers

Answered by mishradhruv242
0

Answer:

#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", n, nth_ap(a,d,n));

return 0;

}

Explanation:

1: Take first term A, common difference D, and N the number of series.

2: Then calculate nth term by (A + (N - 1) * D)

3: Return the Output obtained from the above calculation.

Similar questions