Skills101
← All practice quizzes

Quiz: C++ Introduction

5 questionsNo time limitPass: 60%+10 XP on first pass

What C++ adds to C, your first program, cin and cout, namespaces, the string class, auto and range-based for loops — with every program compiled and checked.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    #include <iostream>
    using namespace std;
    int main() {
        cout << 7 / 2 << " " << 7 / 2.0;
        return 0;
    }
    
  2. Question 2

    Which reads a full line including spaces into a string s?

  3. Question 3

    What does this print?

    #include <iostream>
    #include <string>
    using namespace std;
    int main() {
        string s = "placement";
        cout << s.substr(2, 4);
        return 0;
    }
    
  4. Question 4

    In which namespace do cout and string live?

  5. Question 5

    What does for (auto& x : v) x *= 2; do?