C-Quiz: Operators & Integer Division

This C quiz is about the arithmetic operators and the surprises of integer division. You will predict what /, %, ++ and mixed expressions give and spot classic operator bugs like = instead of ==.

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) {
    printf("%d\n", 7 / 2);
    return 0;
}
Lösung zeigen

D. 3 Both operands are int, so / does integer division and throws away the fraction. The result is 3, not rounded up to 4 and never 3.5.

Darum geht es in diesem Quiz

  • Integer division drops the fraction
  • % and negative numbers
  • Mixing int and double in an expression
  • Post-increment and operator precedence
  • = vs == and short-circuit &&

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.