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.

ふつう 10問 約6分 合格ライン 80% C17

モードを選ぶ

ゲストとしてプレイ中です。ログインすると XP と連続記録が保存されます。

例題

第1問 / 全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;
}
答えを見る

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.

このクイズの内容

  • 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

よくある質問

アカウントは必要ですか?

いいえ、誰でも遊べます。ログインすると XP、連続記録、バッジ、履歴が保存されます。

何度でも挑戦できますか?

はい。ベストスコアが記録され、問題と選択肢は毎回シャッフルされます。