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

Add Bubble Sort #313

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}