Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

#include<stdio.

h>
#include<conio.h>
#define SIZE 100
int main()
{
int i,j,temp,n;
int a[SIZE];
printf("How Many Numbers User Wants to sort : ");
scanf("%d",&n);
printf("Enter %d Numbers to Sort :\n ",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Before Sort : ");
for(i=0;i<n;i++)
{
printf("% d",a[i]);
}
//Sort
for(j=0;j<n;j++)
{
for(i=0;i<=j;i++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}

}
//Ascending//
printf("\nOrder Using Bubble Sort : ");
for(i=0;i<n;i++)
{
printf("% d",a[i]);

}
return 0;
getch();
}

You might also like