Q. What will be the output of the following code?
Code:#include <stdio.h>
int main() {
int i = 0;
for(i = 0; i < 3; i++) {
static int x = 0;
x++;
printf("%d ", x);
}
return 0;
}
β
Correct Answer: (B)
1 2 3
Explanation: Static variables retain their value between function calls/iterations.