#include <iostream.h>
#include <conio.h>
void bubblesort(int [],int);
void main()
{clrscr();
int AR[50],item,n,index;
cout<<"\n\t HOW MANY ELEMENT DO U WANT TO CREATE ARRAY WITH";
cin>>n;
cout<<"\n\t ENTER ARRAY ELEMEMT";
for(int i=0;i<n;i++)
cin>>AR[i];
bubblesort(AR,n);
cout<<"\n\n THE SORTED ARRAY IS AS SHOWN BELOW";
for(i=0;i<n;i++)
cout<<AR[i]<<"_";
cout<<endl;
getch();
}
void bubblesort(int AR[],int size)
{
int tmp,ctr=0;
for(int i=0;i<size;i++)
{ for(int j=0;j<(size-1)-i;j++)
{if (AR[j]<AR[j+1])
{ tmp=AR[j];
AR[j] =AR[j+1];
AR[j+1]=tmp; }
}
cout<<"ARRAY AFTER INERATION"<<++ctr<<"is";
for(int k=0;k<size;k++)
cout<<AR[k]<<" ";
cout<<endl;
}}
SCREEN SHORT : OUTPUT
BUBBLE SORT PRORAME PREVIEW |