Examveda

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);
}

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

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it