Tricky C Questions

These C questions look simple but hide a trap, from chained comparisons and integer promotion to octal literals and const pointers. The quiz is for experienced programmers preparing for interviews who want to explain not only what happens but why.

ยาก 10 ข้อ ~8 นาที ผ่านที่ 80% C17

เลือกโหมด

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

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

ข้อ 1 จาก 10

According to the C standard, what is the value of 10 > 5 > 1?

ดูเฉลย

A. 0, because it means (10 > 5) > 1, which is 1 > 1 C has no chained comparisons: > groups left to right and gives 0 or 1, so 10 > 5 becomes 1 and 1 > 1 is 0. The trap is common enough that recent clang versions reject it by default; write 10 > 5 && 5 > 1 for the maths meaning.

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

  • Chained comparisons and operator precedence with shifts
  • Integer promotion with ~ and float vs double comparisons
  • Unsigned loop counters and loops with an empty body
  • Octal literals, joined string literals and the type of 'a'
  • const int * vs int *const

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

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

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

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

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