Bubble Sort in C: Bubble sort is a simple sorting algorithm. This sorting algorithm is comparison-based algorithm in which each pair of adjacent elements is compared and the elements are swapped if they are not in order. This algorithm is not suitable for large data sets as its average and worst case complexity are of O(n2 ) where n is the number of items.

## Bubble Sort in C

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <stdio.h> int main() { int a[50],n,i,j,temp; printf("Enter the size of array: "); scanf("%d",&n); printf("Enter the array elements: "); for(i=0;i< n;++i) scanf("%d",&a[i]); for(i=1;i< n;++i) for(j=0;j<(n-i);++j) if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } printf("\nArray after sorting: "); for(i=0;i< n;++i) printf("%d ",a[i]); return 0; } |

**OUTPUT of Bubble Sort in C **

You can learn about C Program to Read Infinite Numbers and Arrange Them in Ascending Order here and for more quires you can go to quora .