#include<stdio.h>
#include<conio.h>
void main()
{
int n,a[10],temp,i,j;
printf("enter the limit:\n ");
scanf("%d",&n);
printf("enter the numbers to be sorted:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("the sorted form of number using bubble sort are:\n");
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
}
#include<conio.h>
void main()
{
int n,a[10],temp,i,j;
printf("enter the limit:\n ");
scanf("%d",&n);
printf("enter the numbers to be sorted:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("the sorted form of number using bubble sort are:\n");
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
}
No comments:
Post a Comment