Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    template <class T7gt;
    T Maximum(T& p, T& q)
    {
    return (p > q ? p : q);
    }
    int main ()
    {
    int k = 6, L = 9, S;
    long Lon = 12, a = 13, b;
    S = Maximum(k, L);
    b = Maximum(Lon, a);
    cout << S << endl;
    cout << b << endl;
    return 0;
    }
    1. 6
      9
    2. 12
      13
    3. 9
      13
    4. 13
      9
    5. None of these
Correct Option: D

In this program, We are using the ternary operator on the template function.



Your comments will be displayed only after manual approval.