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 и серию.

Пример вопроса

Вопрос 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, серию, значки и историю.

Можно пройти ещё раз?

Да. Лучший результат сохраняется, а вопросы и ответы каждый раз перемешиваются.