← 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;
}
- A.11 22 33
- B.11 12 13
- C.11 11 11
- 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 →