//coded by Z
#include<stdio.h>
void main()
{
int z,b,n,temp,a[20];
clrscr();
printf("\n\n\nEnter the limit\n\n\t");
scanf("\t%d",&n);
for(z=0;z<n;z++)
scanf("\t%d",&a[z]);
for(z=0;z<=n-1;z++)
{
for(b=0;b<=n-2;b++)
if(a[b]>a[b++])
{
temp=a[b];
a[b]=a[b+1];
a[b++]=temp;
}
}
printf("\n\nthe bubble sorted array\n");
for(z=0;z<=n-1;z++)
printf("\n\t%d",a[z]);
getch();
}
No comments:
Post a Comment