GATE CS 2012 · Question 48 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer
Common Data for Questions 48 and 49: Consider the following C code segment.
int a, b, c = 0; void prtFun(void); main( ) static int a = 1; /* Line 1 */ prtFun( ); a += 1; prtFun( ); printf(“ %d %d ”, a, b); void prtFun(void) static int a = 2; /* Line 2 */ int b = 1; a += ++b; printf(“ %d %d ”, a, b);
What output will be generated by the given code segment?
- (A) 3, 1; 4, 1; 4, 2
- (B) 4, 2; 6, 1; 6, 1
- (C) 4, 2; 6, 2; 2, 0
- (D) 3, 1; 5, 2; 5, 2
Answer
Answer (C)
Answer from the official GATE CS 2012 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes