Output-Based C Questions

Many C interviews start with "what does this print?". This quiz gives you short, complete C programs that test post-decrement loops, chained and compound assignments, nested ternaries, the comma operator and logical operators, so you can practise reading code the way the compiler does.

Mittel 10 Fragen ~6 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 n = 3;
    while (n--) {
        printf("%d ", n);
    }
    printf("| %d\n", n);
    return 0;
}
Lösung zeigen

B. 2 1 0 | -1 n-- tests the old value and then decrements, so the body sees 2, 1 and 0. The final test reads 0 (false) but still decrements, leaving n at -1.

Darum geht es in diesem Quiz

  • while (n--) and where the counter ends up
  • break in nested loops
  • Chained and compound assignment
  • Nested ?: and the comma operator in for
  • Logical operators always give 0 or 1

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.