Bubble Sort Technique Program in C++

Bubble Sort Technique Program in C++

Program to implement the Bubble Sort Technique in C++

Bubble Sort Technique Program in C++
Bubble Sort Technique
#include<iostream.h>
#include<conio.h>
void main()
{
int List[100],n,i,j;
cout<<"Enter the size of the list\n";
cin>>n;
cout<<"Enter the elements of the list\n";
for(i=0;i<n;i++)
cin>>List[i];
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1;j++)
{
if(List[j]>List[j+1])
{
int t = List[j];
List[j]=List[j+1];
List[j+1]=t;
}
}
}
cout<<"The Elments in Ascending Order after Bubble Sort are:\n";
for(i=0;i<n;i++)
cout<<List[i]<<", ";
getch();
}

Comments