Bubble Sort Algorithm in C


In this article, we will see very Simple implementation of Bubble Sort Algorithm in C

Simple Bubble Sort Algorithm implementation in C programming language
#include <stdio.h> int main() { int a[]={1,5,3,2,4}; int n=sizeof(a)/sizeof(int); for(int i=0;i<n;i++) { for(int j=0;j<n-1;j++) { if(a[j]>a[j+1]) { int temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("after sorting \n"); for(int i=0;i<n;i++) { printf("%d ",a[i]); } return 0; }

Why It is called bubble sort?

The bubble sort gets its name because elements tend to move up into the correct order like bubbles rising to the surface.



Need any Help?

Hot Deals ends in

Technical Quiz:

Search Tags

    Simple Bubble Sort Algorithm in C

    C program for Bubble Sort

    C program for Sinking Sort