24 bytes

  • HOME
  • Algorithms
    blue
  • Bubble Sort
  • Bucket Sort
  • Insertion Sort
  • Selection Sort
  • Merge Sort
  • Quick Sort
  • Heap Sort
  • Counting Sort
  • Stack
  • Queue
  • Double Linked List
  • Binary Search Tree
  • Towers OF Hanoi

  • Java Programs
    green bullet
  • Download RMI Calculator
  • Download file
  • Clock applet
  • File Upload
  • JDOM Parser
  • Client server
  • Udp Client server
  • Sudoku Solver

  • System Programming
  • Newtwork Sniffer
  • Good Links
    green bullet
  • Free Source Code
  • Top Coder
  • Code Project
  • Learn Today
  • Concept
  • Intresting Programs
    green bullet
  • Prime Number
  • GCD Euclids
  • Permutations


  • Google
     
    Web 24bytes.com



    Download Bubble Sort in C++
    #include <stdio.h>
    #include <iostream.h>
    
    void bubbleSort(int *array,int length)//Bubble sort function 
    {
    	int i,j;
    	for(i=0;i<10;i++)
    	{
    		for(j=0;j<i;j++)
    		{
    			if(array[i]>array[j])
    			{
    				int temp=array[i]; //swap 
    				array[i]=array[j];
    				array[j]=temp;
    			}
    
    		}
    
    	}
    
    }
    
    void printElements(int *array,int length) //print array elements
    {
    	int i=0;
    	for(i=0;i<10;i++)
    		cout<<array[i]<<endl;
    }
    
    
    void main()
    {
    
    	int a[]={9,6,5,23,2,6,2,7,1,8};   // array to sort 
        bubbleSort(a,10);                 //call to bubble sort  
    	printElements(a,10);               // print elements 
    }
    
    
    . original template by Aran Down.