C++ Program for Sorting An Array

C++ – Sorting An Array C Language Program Code

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

Add Comment