Q.WAP to input 10 elements in an array and then display these
elements in reverse order.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[10];
int i=0;
for(i=0;i<10;i++)
{
cout<<"Enter element no."<<i+1<<"=";
cin>>arr[i];
cout<<endl;
}
cout<<"Given array is:";
for(i=0;i<10;i++)
{
cout<<arr[i]<<" ";
}
cout<<endl<<"Array in reversed order:";
for(i=9;i>=0;i--)
{
cout<<arr[i]<<" ";
}
getch();
}
elements in reverse order.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[10];
int i=0;
for(i=0;i<10;i++)
{
cout<<"Enter element no."<<i+1<<"=";
cin>>arr[i];
cout<<endl;
}
cout<<"Given array is:";
for(i=0;i<10;i++)
{
cout<<arr[i]<<" ";
}
cout<<endl<<"Array in reversed order:";
for(i=9;i>=0;i--)
{
cout<<arr[i]<<" ";
}
getch();
}
No comments:
Post a Comment