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.

Hard 10 questions ~8 minutes Pass at 80% C17

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

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

Show the answer

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.

What this quiz covers

  • 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

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.