C Program to Sort an Array in Ascending Order

#include<stdio.h>
#include<conio.h>
void main()
{
int a[40],n,i,j, temp;
clrscr();
printf("How many numbers you want to give ?");
scanf("%d",&n);
printf("Enter the list of numbers :");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;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("Numbers in ascending order :);
for(i=0;i<n;i++)
printf("%6d",a[i]);
getch();
}

Output:

C Program to Sort an Array in Ascending Order