//Bubble Sort
//BCA Support
//www.bcasupport.xyz
#include <iostream.h>
#include <conio.h>
int num[10],a,b,temp,pass=0;
void bubble();
void main()
{
clrscr();
cout<<"\nEnter 10 numbers :\n";
for(a=0;a<10;a++)
cin>>num[a];
bubble();
cout<<"\nSorted list :";
for(a=0;a<10;a++)
cout<<endl<<num[a];
getch();
}
void bubble()
{
for(a=0;pass<9;pass++)
{
for(b=a+1;b<(10-pass);)
{
if(num[b]<num[a])
{
temp=num[a];
num[a]=num[b];
num[b]=temp;
}
a=b;
b=a+1;
}
a=0;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.