#include<stdio.h>
void main()
{
int a[100];
int n,i,j,temp;
printf("\n Enter the Limit : ");
scanf("%d",&n);
printf("\n Enter %d elements.......\n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
{
for(j=n-1;j>i;j--)
{
if(a[j-1]>a[j])
{
temp=a[j-1];
a[j-1]=a[j];
a[j]=temp;
}
}
}
printf("\n Array after Bubble Sort......\n");
for(i=0;i<n;i++)
printf("\t %d\t",a[i]);
}
No comments:
Post a Comment