#include <iostream>
using namespace std;
 template <class T>
 void bubbleSort(T a[], int n)
{
    for (int i = 0; i < n - 1; i++)
        for (int j = n - 1; i < j; j--)
            if (a[j] < a[j - 1])
                swap(a[j], a[j - 1]);
}
  
         const int n=5;
int main()
{
    int a[n] = { 10, 50, 30, 40, 20 };
    float b[n]={ 1.5, 2.6,1.9,4.7, 2.8 };
    bubbleSort<int>(a, n);
  
    cout << " Sorted integer array : ";
    for (int i = 0; i < n; i++)
        cout << a[i] << " ";
    cout << endl;
    bubbleSort<float>(b, n);
  
    cout << " Sorted float array : ";
    for (int i = 0; i < n; i++)
        cout << b[i] << " ";
    cout << endl;
    return 0;
}

     
           
Note: Need to be arranged in compiler after copied
   

 OutPut:

Sorted integer array : 10 20 30 40 50
Sorted float array : 1.5 1.9 2.6 2.8 4.7