C Program for SORTING OF NUMBERS
main()
{
int a[20],i,j,temp,n;
clrscr();
printf("ENTER THE MAXIMUM LIMIT: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("ENTER %d ELEMENT: ",i);
scanf("%d",&a[i]);
}
for(i=1;i<=n-1;i++)
for(j=i+1;j<=n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("\nTHE SORTED ELEMENTS ARE. \n");
for(j=1;j<=n;j++)
printf(" %d",a[j]);
getch();
}
OUTPUT :
ENTER THE MAX. LIMIT: 5
ENTER 1 NO: 5
ENTER 2 NO: 8
ENTER 3 NO: 10
ENTER 4 NO: 1
ENTER 5 NO: 2
THE SORTED ELEMENTS ARE:
1 2 5 8 10