C Program for bubble sorting

#include<stdio.h> int main(){ int count, temp, i, j, number[30]; printf(“How many numbers are u going to enter?: “); scanf(“%d”,&count); printf(“Enter %d numbers: “,count); for(i=0;i<count;i++) scanf(“%d”,&number[i]); for(i=count-2;i>=0;i–){ for(j=0;j<=i;j++){ if(number[j]>number[j+1]){ temp=number[j]; number[j]=number[j+1]; number[j+1]=temp; } } } printf(“Sorted elements: “); for(i=0;i<count;i++) printf(” %d”,number[i]); return 0; }  

Bubble Sort Algorithm

algorithm

Bubble Sort : Overview Bubble sort is considered the simplest sorting algorithm. Bubble Sort is used to sort a given set of n elements provided in form of an array with n number of elements. Bubble Sort compares all the element one by one and sort them based on their values. It is known as … Read more