#include<iostream.h>
#include<conio.h>
void main()
{
int a[20],i,j,t;
clrscr();
cout<<"Enter 20 numbers : ";
for(i=0;i<20;i++)
cin>>a[i];
for(i=0;i<20;i++)
{
for(j=i+1;j<20;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
cout<<"Ascending order : "<<"\n";
for(i=0;i<20;i++)
cout<<a[i]<<"\n";
cout<<"Descending order : "<<"\n";
for(i=19;i>=0;i--)
cout<<a[i]<<"\n";
getch();
}
No comments:
Post a Comment