ควิซ C: 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.

ง่าย 10 ข้อ ~5 นาที ผ่านที่ 80% C17

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

ตัวอย่างคำถาม

ข้อ 1 จาก 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;
}
ดูเฉลย

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.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • 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

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง