Write a Program to Print An Array in Reverse Order

#include<iostream.h>
#include<conio.h>
#define MAXARRAY 10
void main(){
 clrscr();
 //Variables
 int n,i=0,ARRAY[MAXARRAY];
 //ARRAY LENGTH
 cout<<"Enter the Length of an ARRAY : ";
 cin>>n;
 if(n>MAXARRAY){
	cout<<" Sorry MAX ARRAY Length is 10 ";
 }else{
	//Store into ARRAY
	for(i=0;i<n;i++){
		cout<<" Enter a Value for ARRAY["<<i<<"] : ";
		cin>>ARRAY[i];
	}
	//Display Array
	cout<<"\n Display Array ";
	for(i=0;i<n;i++){
		cout<<"\n ARRAY["<<i<<"] = "<<ARRAY[i];
	}
	//Display Array in Reverse
	cout<<"\n Display Array in Reverse ";
	for(i=n-1;i>=0;i--){
		cout<<"\n ARRAY["<<i<<"] = "<<ARRAY[i];
	}
 }
 getch();
}

Program Output

Reverse Array
Reverse Array
(Visited 97 times, 1 visits today)
Share with Friends :
Written by:

Leave a Reply

Your email address will not be published. Required fields are marked *