Posted by : Unknown Wednesday, October 9, 2013


There's a lot of methods to sort an array.but here i discussed about Bubble Sorting.

Bubble Sorting

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int arr[10],temp;
    cout<<"Enter The Elements in array";
    for(int i=0; i<5;i++)
    {
     cout<<"Enter Element at index["<<i<<"]\t";
     cin>>arr[i];      
    }
    cout<<"\nArray before Sorting\n";
     for(int i=0; i<5;i++)
    {
             cout<<arr[i]<<endl;
    }
     cout<<"\nArray After Sorting\n";
    for(int i=0; i<5;i++)
     for(int i=0; i<4;i++)
    {
     if(arr[i]>arr[i+1])
     {
                        temp=arr[i];
                        arr[i]=arr[i+1];
                        arr[i+1]=temp;
     }        
    }
     for(int i=0; i<5;i++)
    {
             cout<<arr[i]<<endl;
    }
    getch();
}


I hope this is helpful for you.....

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Let's Join Us

This blog is for Computer Programming Learner or who is interested in to learn different programming languages

Get Toolbar Free

Get our toolbar!

FeedBurner FeedCount

Computer Problems

Total Pageviews

Popular Post

Labels

About Us

I am a student Of computer Engineering , Studying at UET Taxila. Web development and Programming is my passion. http://about.me/umair.tariq

Top Commentators

Followers

Powered by Blogger.

Recent comments

- Copyright © Computer Problems -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -