adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename T> 
    inline T square(T x)
    {
        T result;
        result = x * x;
        return result;
    };
    int main()
    {
        int i, ii;
        float x, xx;
        double y, yy;
        i = 2;
        x = 2.2;
        y = 2.2;
        ii = square(i);
        cout << i << " "  << ii << endl;
        yy = square(y);
        cout << y << " " << yy << endl;
    }

a.

2 4

b.

2 4

c.

error

d.

runtime error

Answer: (b).2 4

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?