Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 1 : 123
Advertisement
Detailed Solution
सही उत्तर 123 है।
Key Points
Helpful?
Question:
What does the following C program with a static variable output? / static चर वाले निम्नलिखित C प्रोग्राम का आउटपुट क्या है?
#include <stdio.h> void counter() { static int n = 0; printf("%d", ++n);} int main() { counter(); counter(); counter(); return 0;}
1.
123
2.
111
3.
012
4.
000
Correct Answer: 123
A static local variable keeps its value between calls, so n becomes 1, 2, 3 across the three calls: 123. / static स्थानीय चर कॉल के बीच अपना मान बनाए रखता है, इसलिए तीनों कॉल में n क्रमशः 1, 2, 3 होता है: 123।
Downloaded from PrepSnap (prepsnap.in)