#include<stdio.h>
main()
{
int
a[10],n,i,j,t;
clrscr();
printf("\nEnter
number of elements\n");
scanf("%d",&n);
printf("\nEnter
array elements:\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
printf("\nSorted
list: \n");
for(i=0;i<n;i++)
printf("%d\t",a[i]);
getch();
}
Comments
Post a Comment