C++ Program for Sorting

C++ – Sorting C Language Program Code

#include
#include
void main()
{
int a[30],n,i,pos,min,temp,j;
clrscr();
cout<<"Enter the value of n:";
cin>>n;
cout<<"nEnter the numbers:n";
for(i=0;i {
cin>>a[i];
}
for(i=0;i {
min=a[i];
pos=0;
for(j=i+1;j {
if(a[j] {
min=a[j];
pos=j;
}
}
if(pos>0)
{
temp=a[i];
a[i]=a[pos];
a[pos]=temp;
}
}
cout<<"nSorted array:n";
for(i=0;i {
cout< }
getch();
}

Add Comment