Bubble Sort Algorithm in C Programming

by Dinesh 2013-12-08 13:54:48

Bubble Sort Algorithm in C Programming

Bubble Sort Algorithm Code

#include
#include
void main()
{
int i,n,telemnt,j,arr[25];
clrscr();
printf("Enter the Total Number of Elements: ");
scanf("%d",&n);
printf("
Enter the Elements:

");

for(i=0 ; i {
printf(" Array[%d] = ",i);
scanf("%d",&arr[i]);
}

for(i=0 ; i {
for(j=0 ; j {
if(arr[j]>arr[j+1])
{
telemnt=arr[j];
arr[j]=arr[j+1];
arr[j+1]=telemnt;
}
}
}

printf("
The Sorted Array is:

");
for(i=0 ; i {
printf(" %4d",arr[i]);
}
getch();
}

903
like
0
dislike
0
mail
flag

You must LOGIN to add comments