Source Code : Program On Bubble

//……..Program On Bubble……..//

#include

#include

//using namespace std;

template

void bubble(t a[],int n)

{

  for(int i=0;i

  {

    for(int j=n-1;i

    {

  if(a[j]

  {

    swap(a[j],a[j-1]);

  }

    }

  }

}

template

void swap(x &a,x &b)

{

  x temp=a;

  a=b;

  b=temp;

}

int main()

{

  clrscr();

  int x[5]={10,50,30,40,20};

  float y[5]={1.1,5.5,3.3,4.4,2.2};

  bubble(x,5);

  bubble(y,5);

  cout<<"Sorted x-array:";

  for(int i=0;i<5;i++)

  cout<

  cout<

  cout<<"Sorted y-array:";

  for(int j=0;j<5;j++)

  cout<

  cout<

  getch();

  return(0);

}