Featured
- Get link
- X
- Other Apps
C program to reverse an int array
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[10];int i,j,temp;
for(i=0;i<10;i++)
{
cout<<"\nEnter No."<<i+1<<"\n";
cin>>arr[i];
}
cout<<"You Entered \n";
for(i=0;i<10;i++)
{
cout<<arr[i]<<"\t";
}
for(i=0,j=9;i<10/2;i++,j--)
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
cout<<"Now Reversed Array \n";
for(i=0;i<10;i++)
{
cout<<arr[i]<<"\t";
}
getch();
}
OUTPUT:
#include<conio.h>
void main()
{
clrscr();
int arr[10];int i,j,temp;
for(i=0;i<10;i++)
{
cout<<"\nEnter No."<<i+1<<"\n";
cin>>arr[i];
}
cout<<"You Entered \n";
for(i=0;i<10;i++)
{
cout<<arr[i]<<"\t";
}
for(i=0,j=9;i<10/2;i++,j--)
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
cout<<"Now Reversed Array \n";
for(i=0;i<10;i++)
{
cout<<arr[i]<<"\t";
}
getch();
}
OUTPUT:
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment