Computer Science, asked by Akku486, 9 months ago

The program must accept N numbers as the input. The program must print 1st and Nth number, then 2nd and (N-1)th number and so on. Example Input/Output: Input: 7 10 20 30 40 50 60 70 Output: 10 70 20 60 30 50 40 in c program

Answers

Answered by Anonymous
2

Answer:

// CPP Program to find nth term of

// Arithmetic progression

#include <bits/stdc++.h>

using namespace std;

int Nth_of_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);

}

// Driver code

int main()

{

// starting number

int a = 2;

// Common difference

int d = 1;

// N th term to be find

int N = 5;

// Display the output

cout << "The "<< N

<<"th term of the series is : "

<< Nth_of_AP(a,d,N);

return 0;

}

Similar questions