215 views

2 Answers

5 5 votes

Here, $\texttt{a}$ is a global variable.

Global variables are automatically initialized to $\texttt{0}$ if no value is given.

Also, $\texttt{b}$ is a static global variable.

Static variables are also automatically initialized to $\texttt{0}$ if no value is given.

So, $\texttt{a = 0}$ and $\texttt{b = 0}$.

Therefore, the output is $\texttt{0\ 0}$.

Answer: A

Answer:
Position:
Show:

Related questions

7 7 votes
2 2 answers
215
215 views
GO Classes asked Jun 9
215 views
What is the output of the following code?#include <stdio.h int x = 10; int main() { int x = 20; printf("%d", x); return 0; }
6 6 votes
3 3 answers
252
252 views
GO Classes asked Jun 9
252 views
What is the output of the following code?#include <stdio.h int main() { register int x = 10; int *p = &x; printf("%d", *p); return 0; }$\texttt{10}$ $\texttt{0}$ Garbage ...
8 8 votes
2 2 answers
223
223 views
GO Classes asked Jun 9
223 views
What can be said about the output of the following code?#include <stdio.h int main() { auto int x; printf("%d", x); return 0; }Output is always $\texttt{0}$ Output is alw...
7 7 votes
2 2 answers
245
245 views
GO Classes asked Jun 9
245 views
What is the output of the following code?#include <stdio.h void fun() { static int x = 1; x = x + 2; printf("%d ", x); } int main() { fun(); fun(); fun(); return 0; }$\te...