Skip to content
KALANBLON
Show contents

Chapter 6 of 6 · 10 min

Quiz: repeating

while, do while, for, break and continue: let's check that your loops always stop at the right moment. You need 70% correct answers.

Quiz

6 questions · pass mark: 70%

  1. 1.How many times is "Hi" displayed?

    One answer

    for (int i = 0; i < 4; i++) {
        printf("Hi\n");
    }
  2. 2.What does this code display?

    One answer

    int n = 10;
    while (n > 10) {
        printf("%d\n", n);
        n--;
    }
    printf("end\n");
  3. 3.Which loop runs its block at least once, even if the condition is false?

    One answer

  4. 4.Fill in the keyword that leaves the loop immediately.

    Complete the code

    for (int i = 0; i < 100; i++) {
        if (i * i > 50) {
            ____;
        }
    }
  5. 5.Which loops never stop? (several answers)

    Several answers possible

  6. 6.What does this code display?

    One answer

    for (int i = 1; i <= 5; i++) {
        if (i == 3) {
            continue;
        }
        printf("%d ", i);
    }

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