🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Operators and Templates: all 10 questions

Quiz: Operators and Templates · Question 8 of 10

What does this print? (code)

What does this print?

#include <iostream>
#include <string>
using namespace std;
template <typename T>
T biggest(T a, T b) { return a > b ? a : b; }
int main() {
    cout << biggest(4, 9) << " " << biggest(2.5, 1.5) << " " << biggest<string>("pune", "agra") << "\n";
    return 0;
}
  1. A.9 2.5 agra
  2. B.9 2 pune
  3. C.9 2.5 pune
  4. D.Compile error
Answer & explanation

Correct answer: 9 2.5 pune

The template is generated for int, double and string; "pune" > "agra" alphabetically.

Can you get the rest right without peeking?

Take the timed Quiz: Operators and Templates quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →