Skills101
← All practice quizzes

Quiz: References and Functions

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

References as another name for a variable, pass by value vs by reference vs by const reference, function overloading, default arguments and inline functions.

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;
    void f(int &x) { x = x * 2; }
    int main() {
        int a = 7;
        f(a);
        cout << a;
        return 0;
    }
    
  2. Question 2

    Which is true about references?

  3. Question 3

    How should a function receive a large vector it only reads?

  4. Question 4

    What does this print?

    #include <iostream>
    using namespace std;
    int add(int a, int b = 10, int c = 100) { return a + b + c; }
    int main() {
        cout << add(1, 2);
        return 0;
    }
    
  5. Question 5

    Two functions named area(int) and area(int, int) in the same program is an example of: