🎙 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 3 of 10

What does this print? (code)

What does this print?

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

Correct answer: 12

The static n keeps its value: calls return 10, 11, then 12.

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 →