Computer Science, asked by rautyash0324, 2 months ago

Write a program to do multiplication using a function template.​

Answers

Answered by bhartishree1996
0

Answer:

#include <iostream.h>

using namespace std;

template <typename T>

T multiplication(T num1, T num2) {

return (num1*num2);

}

int main() {

int result1;

double result2;

// calling with int parameters

result1= multiplication<int>(2, 3);

cout << result << endl;

// calling with double parameters

result2 = multiplication<double>(2.2, 3.3);

cout << result2 << endl;

return 0;

}

Similar questions