C Quiz: 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 और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 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, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।