PROGRAM:
#include <iostream.h>
#include <conio.h>
const int N=10;
void main() {
int a[N],temp,i,j;
clrscr();
cout<<"Enter ten values to be sorted:\n";
for(i=0;i<N;i++) {
cout<<"Enter Value "<<i+1<<" : ";
cin>>a[i];
}
for(i=0;i<N-1;i++)
for(j=0;j<N-1;j++)
if(a[j]>a[j+1]) {
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
cout<<"\nThe sorted array is: \n";
for(i=0;i<N;i++) {
cout<<"\t"<<a[i];
}
getch();
}
No comments:
Post a Comment