#include<stdio.h>
#include<conio.h>
void bubble(int ar[],int n);
void main()
{
int ar[50],n,i;
clrscr();
printf("Enter the no of element : ");
scanf("%d",&n);
printf("\nEnter the no : ");
for(i=0;i<n;i++)
{
scanf("%d",&ar[i]);
}
bubble(ar,n);
printf("\nAfter bubble sort : ");
for(i=0;i<n;i++)
{
printf("%d\n",ar[i]);
}
getch();
}
void bubble(int ar[],int n)
{
int j,i,temp;
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(ar[j]>ar[j+1])
{
temp=ar[j];
ar[j]=ar[j+1];
ar[j+1]=temp;
}
}
}
}
#include<conio.h>
void bubble(int ar[],int n);
void main()
{
int ar[50],n,i;
clrscr();
printf("Enter the no of element : ");
scanf("%d",&n);
printf("\nEnter the no : ");
for(i=0;i<n;i++)
{
scanf("%d",&ar[i]);
}
bubble(ar,n);
printf("\nAfter bubble sort : ");
for(i=0;i<n;i++)
{
printf("%d\n",ar[i]);
}
getch();
}
void bubble(int ar[],int n)
{
int j,i,temp;
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(ar[j]>ar[j+1])
{
temp=ar[j];
ar[j]=ar[j+1];
ar[j+1]=temp;
}
}
}
}
No comments:
Post a Comment