Bubble Sort in C Programming Program | DSA Tutorials YASH PAL, 7 May 20267 May 2026 Bubble sorting is one of the easiest to understand and program in C Programming. It is probably the least efficient. The basic idea underlying the bubble sort is to pass through the file sequentially several times. Each pass consists of comparing each element in the file with its successor and interchanging the two elements if they are not in proper order.If you want a working example of bubble sorting and the steps of the algorithm how the bubble sort algorithm works, then read this tutorial – Bubble sorting algorithm example.Bubble Sorting program in C Programming.#include<stdio.h> #include<conio.h> #define SIZE 10 void bubble_sort(int [], int); void main() { int a[SIZE],n,i; printf("Enter how many elements "); scanf("%d",&n); /*Input array*/ for(i=0;i<n;i++) { printf("Enter element %d ",i+1); scanf("%d",&a[i]); } bubble_sort(a,n); /*Output Array*/ for(i=0;i<n;i++) printf("%d ",a[i]); getch(); } void bubble_sort(int a[], int n) { int i,j,swap,t; swap=1; i=1; while(i<n && swap == 1) { swap = 0; for(j=0;j<n-1;j++) { if(a[j]>a[j+1]) { t = a[j]; a[j] = a[j+1]; a[j+1] = t; swap = 1; } } i++; } }#include<stdio.h> #include<conio.h> #define SIZE 10 void bubble_sort(int [], int); void main() { int a[SIZE],n,i; printf("Enter how many elements "); scanf("%d",&n); /*Input array*/ for(i=0;i<n;i++) { printf("Enter element %d ",i+1); scanf("%d",&a[i]); } bubble_sort(a,n); /*Output Array*/ for(i=0;i<n;i++) printf("%d ",a[i]); getch(); } void bubble_sort(int a[], int n) { int i,j,swap,t; swap=1; i=1; while(i<n && swap == 1) { swap = 0; for(j=0;j<n-1;j++) { if(a[j]>a[j+1]) { t = a[j]; a[j] = a[j+1]; a[j+1] = t; swap = 1; } } i++; } }OutputEnter how many elements 5 Enter element 1 10 Enter element 2 20 Enter element 3 1 Enter element 4 2 Enter element 5 3 1 2 3 10 20 Data Structures Tutorials DSA Tutorials