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.

Difícil 10 perguntas ~8 minutos Aprovação com 80% C17

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 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;
}
Mostrar a resposta

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.

O que este quiz cobre

  • 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

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.