🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Strings in C++: all 10 questions

Quiz: Strings in C++ · Question 3 of 10

What does this print? (code)

What does this print?

#include <iostream>
#include <string>
using namespace std;
int main() {
    cout << (string("Mango") < string("apple"));
    return 0;
}
  1. A.0
  2. B.1
  3. C.Compile error
  4. D.Mango
Answer & explanation

Correct answer: 1

'M' (77) has a smaller code than 'a' (97), so "Mango" comes first.

Can you get the rest right without peeking?

Take the timed Quiz: Strings in C++ quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →