234 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
228
228 views
GO Classes asked Jun 9
228 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
265
265 views
GO Classes asked Jun 9
265 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
238
238 views
GO Classes asked Jun 9
238 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
266
266 views
GO Classes asked Jun 9
266 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...