static & Storage Classes

This C quiz digs into storage classes, the keywords that decide how long a variable lives and who can see it. You will trace static local counters, reason about default initialization and linkage, and spot code that breaks the rules for static and register.

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

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

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

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

Вопрос 1 из 10

What does this print?

#include <stdio.h>

int next(void) {
    static int n = 0;
    n++;
    return n;
}

int main(void) {
    int a = next();
    int b = next();
    int c = next();
    printf("%d %d %d\n", a, b, c);
    return 0;
}
Показать ответ

C. 1 2 3 A static local is created once, before the program starts, and keeps its value between calls. static int n = 0; is not run again on each call, so n goes 1, 2, 3.

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

  • static local variables keep their value between calls
  • Static initializers run once and must be constant
  • static and extern at file scope (linkage)
  • Default zero initialization of static storage
  • register and why its address cannot be taken

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

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

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

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

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