C++ Program to Print Array in Reverse Order

Write C++ Program to Print Array in Reverse Order

// CPP Program to Print Array in Reverse Order

#include <iostream>

using namespace std;

int main()
{
	int n = 5, A[n], i;

	for(i = 0; i < n; i++)
	{
		cout << "Enter A[" << i << "] :--> ";
		cin >> A[i];
	}
	cout << "Reverse Array :--> ";
	for(i = n - 1; i >= 0; i--)
	{
		cout << A[i] << " ";
	}
	return 0;
}

Output:

Enter A[0] :--> 5
Enter A[1] :--> 4
Enter A[2] :--> 3
Enter A[3] :--> 2
Enter A[4] :--> 1
Reverse Array :--> 1 2 3 4 5

≪ Previous | Next ≫