#include<stdio.h>
void main()
{
int i,j,n,temp,a[10];
printf("\nEnter n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter a[%d]",i);
scanf("%d",&a[i]);
}
for (i = 1; 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("\nSorted ayyay using bubble sort is\n");
for (i = 0; i < n; i++)
{
printf("\n%d", a[i]);
}
}
No comments:
Post a Comment