Bubble Sort

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[10];
cout<<"Enter 10 Oderable intergers: \n";
for(int i=0;i<=9;i++)
cin>>a[i];
cout<<"List after sorted: ";
for(int i=0;i<=9;i++)
for(int j=0;j<=9;j++)
if(a[j]>a[j+1])
{
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
for(int i=0;i<=9;i++)
cout<<"  "<<a[i];
getch();
return 0;
}
Output:

Popular posts from this blog

Shutdown Pc

Ellipse using OpenGl

String Comparisons