🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Strings in C++: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. What does find return when the text is not found?
  3. Q3. What does this print? (code)
  4. Q4. After cin n;, why does getline(cin, line); often return an empty string?
  5. Q5. What does this print? (code)
  6. Q6. Which call splits "a;b;c" into its parts?
  7. Q7. What is the difference between s[i] and s.at(i)?
  8. Q8. Why does the replace-all loop add pos += to.size() after each replacement?
  9. Q9. What does this print? (code)
  10. Q10. Which is the simplest way to check whether two words are anagrams?