Type Casting & Integer Promotion

This C quiz covers explicit casts and the implicit conversions C performs on its own, like integer promotion and the usual arithmetic conversions. You will predict results where the type of an expression changes the answer and spot the classic signed/unsigned trap.

ปานกลาง 10 ข้อ ~6 นาที ผ่านที่ 80% C17

เลือกโหมด

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

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

ข้อ 1 จาก 10

What does this print?

#include <stdio.h>

int main(void) {
    int a = 7, b = 2;
    double r = (double)a / b;
    printf("%.1f\n", r);
    return 0;
}
ดูเฉลย

A. 3.5 The cast applies to a before the division, so it is double / int, and b is converted to double too. The division keeps the fraction: 3.5.

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

  • Casting int to double before or after a division
  • Truncation when converting floating point to int
  • Integer promotion of char and short in expressions
  • Comparing signed and unsigned values
  • Overflow before widening

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

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

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

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

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