Algorithm For Bubble Sort

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
            int a[10],temp,i,j;
            cout<<"Enter values of array"<<endl;
            for(i=0;i<10;i++)
            {
                 
                  cin>>a[i];
            }
            for(i=1;i<10;i++)
            for(j=0;j<10-i;j++)
            if(a[j]>a[j+1])
            {
                  temp=a[j];
                  a[j]=a[j+1];
                  a[j+1]=temp;
            }
            cout<<"Values after sorting are"<<endl;
            for(i=0;i<10;i++)
            {
                  cout<<a[i]<<endl;
            }
      return 0;
}

Comments

Popular posts from this blog

Using Progress Bar In C#

Get elements by class name in javascript

Jquery serer side datatables in asp.net