🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: C Functions and Recursion: all 10 questions

Quiz: C Functions and Recursion · Question 7 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
int x = 5;
int main(void) {
    int x = 10;
    {
        int x = 20;
        printf("%d ", x);
    }
    printf("%d\n", x);
    return 0;
}
  1. A.5 10
  2. B.20 20
  3. C.20 10
  4. D.20 5
Answer & explanation

Correct answer: 20 10

The innermost declaration hides the outer ones inside its block; after the block, the local x (10) is visible again.

Can you get the rest right without peeking?

Take the timed Quiz: C Functions and Recursion quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →