#include <stdio.h>
main()
{
int a[30],n,i,j,temp;
printf("\n how many numbers");
scanf("%d",&n);
if (n>30)
{
printf("\n too many numbers");
}
printf("\n enter the array elements: ");
for (i=0;i<n;i++)
scanf("%d",&a[i]);
for (i=0;i<n-1;i++)
for(j=0;j<(n-i)-1;j++)
if (a[j]>a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
printf("The numbers in sorted order are : \n");
for(i=0;i<n;++i)
printf("\n%d",a[i]);
getch();
}
No comments:
Post a Comment