// Q1:WAP to perform bubble sort
#include
#include
class bubble
{
public:
void sort(int a[],int n);
void input(int a[],int n);
void output(int a[],int n);
};
void main()
{
clrscr();
bubble b;
int i,j,n,a[20],temp;
cout<<"Enter the number of terms:";
cin>>n;
b.input(a,n);
b.sort(a,n);
b.output(a,n);
getch();
}
void bubble::input(int a[],int n)
{
cout<<"Enter the elements...\n";
for(int i=0;i>a[i];
}
}
void bubble::sort(int a[],int n)
{
for(int i=0;ia[j+1])
{
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
void bubble::output(int a[],int n)
{
cout<<"The sorted list (in the ascending order)....\n";
for(int i=0;i....
1
3
4
6
*/