Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

Write a program to implement bubble sort.

Write a program to implement bubble sort.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,pass,ptr,t;
printf("enter the value of n");
scanf("%d",&n);
printf("enter the array element");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
for(pass=0;pass<n-1;pass++)
{
ptr=0;
if(a[ptr+1]<a[ptr])
{
t=a[ptr];
a[ptr]=a[ptr+1];
a[ptr+1]=t;
}
ptr=ptr+1;
}
}
printf("sorted array");
for(i=0;i<10;i++)
{
printf("%d",a[i]);
}
} 

Output


Previous
Next Post »