Write a program to print elements of an array in reverse order

Print Elements of an Array in Reverse Order

Write a program to print elements of an array in reverse order

Object: Write a program to print elements of an array in reverse order. C++ projects for beginners with source code

Code:

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int num[5],i;
cout<<“Enter 5 Numbers.\n”;
for(i=0;i<5;i++)
{
cin>>num[i];
}
cout<<“Array in Original form.\n”;
for(i=0;i<5;i++)
{
cout<<num[i]<<” “;
}
cout<<“\nArray in Reverse form.\n”;
for(i=4;i>=0;i–)
{
cout<<num[i]<<” “;
}
getch();
}

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	int num[5],i;
	cout<<"Enter 5 Numbers.\n";
	for(i=0;i<5;i++)
	{
		cin>>num[i];
	}
	cout<<"Array in Original form.\n";
	for(i=0;i<5;i++)
	{
		cout<<num[i]<<" ";
	}	
	cout<<"\nArray in Reverse form.\n";
	for(i=4;i>=0;i--)
	{
		cout<<num[i]<<" ";
	}
	getch();
}

Output:

Write a program to print elements of an array in reverse order

2 thoughts on “Write a program to print elements of an array in reverse order”

  1. Pingback: Top 40 projects with C++ for beginners in 2021

  2. Pingback: C++ projects for beginners with source code - Codeboks

Leave a Comment

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