← Quiz: Storage Classes in C: all 15 questions
Quiz: Storage Classes in C · Question 1 of 15
What does this print? (code)
What does this print?
#include <stdio.h>
void f(void) {
static int s = 5;
int a = 5;
s++; a++;
printf("%d %d ", s, a);
}
int main(void) {
f(); f(); f();
return 0;
}
- A.6 6 6 6 6 6
- B.6 6 7 6 8 6
- C.6 6 7 7 8 8
- D.5 5 6 5 7 5
Answer & explanation
Correct answer: 6 6 7 6 8 6
s is created once and keeps counting (6, 7, 8); a is a new variable set to 5 on every call, so it always prints 6.
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 →