Wednesday 26 October 2011

implementation of bubble sort

//program is implemented by shadab khan
#include<iostream.h>
#include<conio.h>
void main()
{
            clrscr();
            int a[5], i,j,t;
            cout<<”enter the 5 element of array”;
            for(i=0;i<=4;i++)
            cin>>a[0];
            for(i=0;i<=4;i++)
            {
                        for(j=0;j<=4-I;j++)
            {
                        if(a[j]>a[j+1])
                        {
                                    t=a[j];
                                    a[j]=a[j+1];
                                    a[j+1]=t;
                        }
            }
            }
            cout<<”5 sorted elements of array”;
            for(i=0;i<=4;i++)
            cout<<a[i];
            getch();
}

No comments:

Post a Comment