C++ Tutorial menu

C++ Quiz

Check what you have learned in this C++ tutorial. Pick an answer and read the explanation that follows.

Tips

  • Answer each question before checking
  • Revisit the chapter for any question you miss
  • Compile small test programs to prove the answers to yourself

Quiz Questions

Exercise

Which operator is used with cout to send output?

Exercise

What does cout << 7 / 2; print?

Exercise

Which function reads a full line of text, including spaces?

Exercise

How do you turn the number 42 into a string?

Exercise

Which loop runs its body at least once, even when the condition is false?

Exercise

After vector<int> v = {1, 2}; v.push_back(3); what is v.size()?

Exercise

What is the output? void f(int& x) { x = 9; } int a = 1; f(a); cout << a;

Exercise

What is special about a constructor?

Exercise

Which keyword makes a class Car inherit from Vehicle?

What Next?

Well done on finishing the C++ tutorial. Practise by building a student marks system, a shop inventory with vectors, or a simple bank account class. To see a language with similar syntax and automatic memory management, try the C# tutorial.

Learn C++ with a teacher

Join the Python Programming course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp