C-Quiz: if, switch & Loops

This C quiz checks how well you can follow the control flow of a program. You will trace if/else, switch with and without break, and for, while and do-while loops, and spot small bugs like a stray semicolon.

Leicht 10 Fragen ~5 Minuten Bestanden ab 80% C17

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this print?

#include <stdio.h>

int main(void) {
    int x = 2;
    switch (x) {
        case 1: printf("one ");
        case 2: printf("two ");
        case 3: printf("three");
            break;
        default: printf("other");
    }
    printf("\n");
    return 0;
}
Lösung zeigen

B. two three switch jumps to case 2 and then falls through into the following cases until it reaches a break. So it prints two and three, and the break stops it before default.

Darum geht es in diesem Quiz

  • switch fall-through and break
  • for, while and do-while loops
  • break and continue
  • Which if an else belongs to
  • What counts as true in C

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.