// Program to reverse an array
#include<iostream.h>
#include<conio.h>
void main()
{
int arr[10],i,j,temp;
cout<<"Enter an array"<<endl;
for(i=0;i<10;i++)
{
cin>>arr[i];
}
cout<<"The reverse array is"<<endl;
for(i=0,j=9;i<=j;i++,j--)
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
for(i=0;i<10;i++)
{
cout<<arr[i]<<endl;
}
getch();
}
//another way to reverse an array
#include<iostream.h>
#include<conio.h>
void main()
{
int arr[10],arr1[10],i,j;
cout<<"Enter an array"<<endl;
for(i=0;i<10;i++)
{
cin>>arr[i];
}
cout<<"The reverse array is"<<endl;
for(i=0,j=9;i<10;i++,j--)
{
arr1[i]=arr[j];
}
for(i=0;i<10;i++)
{
cout<<arr1[i]<<endl;
}
getch();
}
// program to enter five names and display them
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
char name[5][20];
cout<<"Enter five names"<<endl;
for(int i=0;i<5;i++)
{
gets(name[i]);
}
cout<<"Names entered are"<<endl;
for(i=0;i<5;i++)
{
puts(name[i]);
}
getch();
}