Квиз по C: Scope & Lifetime

This C quiz tests scope (where a name is visible) and lifetime (how long the variable exists). You will trace shadowed variables in nested blocks, loops and functions, and spot dangling pointers and names used out of scope.

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

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

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

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

Вопрос 1 из 10

What does this print?

#include <stdio.h>

int main(void) {
    int x = 1;
    {
        int x = 2;
        printf("%d ", x);
    }
    printf("%d\n", x);
    return 0;
}
Показать ответ

A. 2 1 The inner block declares a new x that shadows the outer one until the closing brace. The outer x was never changed, so the second printf prints 1.

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

  • Block scope and shadowing
  • Loop variables declared in for
  • Global variables and function parameters
  • Automatic variables are recreated each time
  • Dangling pointers to local variables

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

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

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

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

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