what is bubble sort?


the name of this sorting process describes the way it works here the comparisions begin from the bottom most element and the smaller element bubble up towards the top. the value in the 5th element is compared against the value in the 4th element.

condition:- if the value in the 5th element is smaller then the value in the 4th values in th two elements are swapped.

Bubble sort program example in c

#include<stdio.h> int main(){ int i,j,temp,arr_num[5]={23, 90, 9, 25, 16}; for(i=3;i>=0;i--) for(j=4; j>=4-i;j--) { if(arr_num[j]<arr_num[j-1]) { temp=arr_num[j]; arr_num[j]=arr_num[j-1]; arr_num[j-1]=temp; } } printf("\n the sorted array"); for(i=0;i<5;i++) printf("\n%d", arr_num[i]); return 0; }