What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <typename T, typename U>
void squareAndPrint(T x, U y)
{
cout << x << x * x << endl;
cout << y << " " << y * y << endl;
};
int main()
{
int ii = 2;
float jj = 2.1;
squareAndPrint<int, float>(ii, jj);
}
#include <iostream>
using namespace std;
template <typename T, typename U>
void squareAndPrint(T x, U y)
{
cout << x << x * x << endl;
cout << y << " " << y * y << endl;
};
int main()
{
int ii = 2;
float jj = 2.1;
squareAndPrint<int, float>(ii, jj);
}A. 23
2.1 4.41
B. 24
2.1 4.41
C. 24
2.1 3.41
D. 2.1 3.41
Answer: Option B

Join The Discussion