Bubble Sort
      Bubble sort is a sorting algorithm, in every loop an item either max/min according to program is shifted to the end of array. Similarly the second max/min to second last position, O(n^2).
#include<stdio.h>
#include<conio.h>

void Bubble_sort(int *arr, int len)
{
     int i,j,temp;
     
     for(i=0;i<len-1;i++)
     {
        for(j=0;j<len-1;j++)
        {
          if(arr[j]>arr[j+1])
          {
            temp=arr[j];
            arr[j]=arr[j+1];
            arr[j+1]=temp;
          }
        }
     }
}

int main()
{
     int arr[] = {5,4,3,2,1,6,9};
     int i;
     Bubble_sort(arr,7);
     for(i=0;i<7;i++)
     printf(" %d ",arr[i]);
     getch();
     return 0; 
     
}
            
            
     
     
     
									

Download Program
Did You Know ?
IP address is a numerical label that is assigned to devices participating in a computer network. Read More