Skip to content
KALANBLON
Show contents

Chapter 6 of 6 · 10 min

Quiz: repeating

while and for loops, break, continue and std::vector: let's check that you've mastered repetition. You need 70% correct answers.

Quiz

6 questions · pass mark: 70%

  1. 1.How many rounds does this loop make?

    One answer

    for (int i = 0; i <= 10; i++) {
        // ...
    }
  2. 2.What does this code display?

    One answer

    std::vector<int> v = {4, 8};
    v.push_back(15);
    std::cout << v.size() << " " << v[2];
  3. 3.What is the difference between v[i] and v.at(i)?

    One answer

  4. 4.Fill in the blank to be able to change each item in the loop.

    Complete the code

    for (int____ x : grades) {
        x += 1;
    }
  5. 5.Which loops run at least once with int n = 0;? (several answers)

    Several answers possible

  6. 6.What does continue do in a loop?

    One answer

Your progress is saved on this device. Create a free account to keep your progress on all your devices.