//a) /* #include #define size 5 using namespace std; template class ArrayOp { T a1[size]; T a2[size]; public: ArrayOp(T a[] , T b[]) { for(int i = 0;i < size;i++) { a1[i] = a[i]; a2[i] = b[i]; } } void add() { T res[size]; for(int i = 0;i < size ; i++) { res[i] = a1[i] + a2[i]; } display(res); } void display(T res[]) { for(int i = 0;i < size;i++) { cout << res[i] << " "; } } void find(T &min1 , T &min2 , T &max1 , T &max2) { min1 = a1[0]; min2 = a2[0]; max1 = a1[0]; max2 = a2[0]; for(int i = 0;i < size;i++) { if(min1 > a1[i]) min1 = a1[i]; if(min2 > a2[i]) min2 = a2[i]; if(max1 < a1[i]) max1 = a1[i]; if(max2 < a2[i]) max2 = a2[i]; } } }; int main() { int a1[] = { 1 , 2 ,3, 4, 5}; int a2[] = {5 , 4 , 3 , 2, 1}; ArrayOp Ar(a1 , a2);; Ar.add(); int max1 , max2 , min1 , min2; find(min1 , min2 , max1 , max2); cout << "Minimum in array 1: " << min1 << endl; cout << "Minumum in array 2: " << min2 << endl; cout << "Maximum in array 1: " << max1 << endl; cout << "Maximum in array 2: " << max2 << endl; } */ //b) #include using namespace std; template void Bubble_sort(T arr[] , T n) { for(int i = 0;i < n-1;i++) { for(int j = 0;j < n-i-1;j++) { if(arr[j] > arr[j+1]) { T temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } } template void print(T a[] , T n) { for(int i = 0;i < n;i++) { cout << a[i] << " "; } cout << endl; } int main() { int a[] = {44 ,28 , 85 , 3 , 58}; int n = sizeof(a)/sizeof(a[0]); cout << "Before Sorting: " << endl; print(a , n); cout << "After sorting: " << endl; Bubble_sort(a , n); print(a , n); }