Saturday, November 5, 2011

Bubble sort using C laguage


#include<conio.h>
#include<stdio.h>
 void main()
 {
int arr[10],i,temp,j;
clrscr();
printf("Enter the numbers:");
for(i=0;i<=9;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<=9;i++)
{
for(j=i+1;j<=9;j++)
{
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(i=0;i<=9;i++)
{
printf("\n");
printf("  %d",arr[i]);
}
getch();
 }

0 comments:

Post a Comment

You are most welcome for making comments here. I will consider your view and will reply you soon.