Ads Top

ARRAY SORTING PROGRAM USING CPP

#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,a[10],t;

cout<<"enter 10 numbers";
for(i=0;i<10;i++)
cin>>a[i];
for(i=0;i<9;i++)
for(j=i+1;j<10;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
cout<<"the new sorted order is";
for(i=0;i<10;i++)
cout<<a[i]<<endl;
getch();
}

OUTPUT:
Enter 10 numbers:
3
3
3
6
569
58
26
56
258
45
The new sorted order is3
3
3
6
26
45
56
58
258
569


No comments:

Touchfeeds. Powered by Blogger.