🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Storage Classes in C: all 15 questions

Quiz: Storage Classes in C · Question 11 of 15

What does this print? (code)

What does this print?

#include <stdio.h>
void f(void) {
    int a = 0;
    static int s = 0;
    a++;
    s++;
    printf("%d%d ", a, s);
}
int main(void) {
    f(); f(); f();
    printf("\n");
    return 0;
}
  1. A.11 22 33
  2. B.11 12 13
  3. C.11 11 11
  4. D.12 13 14
Answer & explanation

Correct answer: 11 12 13

a is created fresh at 0 on every call; the static s keeps its value, so it counts 1, 2, 3.

Can you get the rest right without peeking?

Take the timed Quiz: Storage Classes in C quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →