CJCoding With Joseph
← Back to Question List
C Code Walkthrough #28

Static Local Keeps Its Value

mediumFunctions

📄 Code

Read carefully — what does this print?
1#include <stdio.h>
2int next() {
3 static int c = 0;
4 c++;
5 return c;
6}
7int main() {
8 int a = next();
9 int b = next();
10 int c = next();
11 printf("%d %d %d\n", a, b, c);
12 return 0;
13}

🎯 Your Answer