Квиз по C: Unions & Enums

This C quiz covers enums, which give names to integer constants, and unions, whose members share the same memory. You will predict enum values, build a tagged union and learn what C does and does not promise about them.

Средний 10 вопроса ~6 минуты Проходной балл: 80% C17

Выберите режим

Вы играете как гость: войдите, чтобы сохранить XP и серию.

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

Вопрос 1 из 10

What does this print?

#include <stdio.h>

enum color { RED, GREEN, BLUE };

int main(void) {
    printf("%d %d %d\n", RED, GREEN, BLUE);
    return 0;
}
Показать ответ

D. 0 1 2 Enum constants are plain integers that start at 0 and go up by one. printf() prints numbers, C has no built-in way to get an enum's name as text.

Что проверяет этот квиз

  • Default and explicit enum values
  • Enums in switch and the COUNT trick for array sizes
  • Why enum constants live in one shared namespace
  • Union members share storage, so the last write wins
  • Tagged unions and the size of a union

Частые вопросы

Нужен ли аккаунт?

Нет. Играть может любой. Войдите, чтобы сохранять XP, серию, значки и историю.

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

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