Comments

Tuesday, August 27, 2013

Bubble sort in assending order

Posted by at 3:53 AM Read our previous post


Object:
Bubble sort using class and object in Accending order
Source Code:

#include <iostream>
using namespace std;

class divide
{
public:
       int *ans(int arry[10])
       {
              int temp;

              for(int num=0;num<9;num++)
              {
                     for(int num1=1;num1<10;num1++)
                     {
                     if(arry[num]>arry[num1])
                     {
                            temp=arry[num];
                           arry[num]=arry[num1];
                           arry[num1]=temp;
                     }
                    
                    
                     }
             
             
              }



              return arry;
       }

};
void main()
{
       divide div;

       int input[10],*ptr;

       cout<<"Enter 10 Digit"<<endl;
      
       for(int num=0;num<10;num++)
       {
              cin>>input[num];
       }

       ptr=div.ans(input);

       for(int count=0;count<10;count++)
       {
              cout<<ptr[count]<<endl;
       }
}

Output:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template