Skip to content
This repository was archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
Merge pull request #313 from AmodhShenoy/master
Browse files Browse the repository at this point in the history
Add Bubble Sort
  • Loading branch information
MJ10 authored Oct 6, 2017
2 parents 85f5c1c + bf965b1 commit f612dd2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions BubbleSort/AmodhShenoy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
int n,temp;
int a[200];
while(true)
{
cout<<"Enter the number of elements"<<endl;
cin>>n;
if(n<=200)
{
cout<<"Enter the elements"<<endl;
for(int i=0;i<n;i++)
cin>>a[i];
for(int j=n-1;j>0;j--)
{
for(int k=0;k<j;k++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
cout<<"The sorted elements are:";
for(int l=0;l<n;l++)
cout<<" "<<a[l];
break;
}
else
cout<<"Number of elements exceeds limit(200). Please try again."<<endl;
}
return 0;
}

0 comments on commit f612dd2

Please sign in to comment.