//WAP TO SORT THE GIVEN ELEMENTS BY USING BUBBLE SORT
BUBBLE SORT
#include<stdio.h>
#include<conio.h>void main()
{
int a[50],n,i,j,temp;
printf("enter the size of array:");
scanf("%d",&n);
printf("enter the array elements:");
for(I=0;i<n;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("\n array after sorting");
for(I=0;i<n;i++)
{
printf("%d",a[i]);
}
}
run this program
Mst programe hai
ReplyDelete