1
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
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("\n %d %d ", a, b);
}
void prtFun(void)
{ 
   static int a=2;   /* Line 2 */
   int b=1;
   a+ = ++b;
   printf("\n %d %d ", a, b);
}
What output will be generated by the given code segment?
A
$$\eqalign{ & 3\,\,1 \cr & 4\,\,1 \cr & 4\,\,2 \cr} $$
B
$$\eqalign{ & 4\,\,2 \cr & 6\,\,1 \cr & 6\,\,1 \cr} $$
C
$$\eqalign{ & 4\,\,2 \cr & 6\,\,2 \cr & 2\,\,0 \cr} $$
D
$$\eqalign{ & 3\,\,1 \cr & 5\,\,2 \cr & 5\,\,2 \cr} $$
2
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
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("\n %d %d ", a, b);
}
void prtFun(void)
{ 
   static int a=2;   /* Line 2 */
   int b=1;
   a+ = ++b;
   printf("\n %d %d ", a, b);
}
What output will be generated by the given code segment if:
Line 1 is replaced by auto int a = 1;
Line 2 is replaced by register int a = 2;
A
$$\eqalign{ & 3\,\,1 \cr & 4\,\,1 \cr & 4\,\,2 \cr} $$
B
$$\eqalign{ & 4\,\,2 \cr & 6\,\,1 \cr & 6\,\,1 \cr} $$
C
$$\eqalign{ & 4\,\,2 \cr & 6\,\,2 \cr & 2\,\,0 \cr} $$
D
$$\eqalign{ & 4\,\,2 \cr & 4\,\,2 \cr & 2\,\,0 \cr} $$
3
GATE CSE 2012
MCQ (Single Correct Answer)
+1
-0.3
What will be the output of the following C program segment?
Char inchar = 'A';
Switch ( inchar ) {
case 'A' : printf ("Choice A\ n") ;
case 'B' :
case 'C' : printf (“Choice B”) ;
case 'D' :
case 'E' :
default : printf ( " No Choice" ) ; }
A
No Choice
B
Choice A
C
Choice A
Choice B No Choice
D
Program gives no output as it is erroneous
4
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.
Program main;
  Var . . .

  Procedure A1;
      Var . . .
      Call A2;
  End A1

  Procedure A2;
      Var . . .

      Procedure A21;
        Var . . .
        Call A1;
      End A21

      Call A21;
  End A2

  Call A1;
End main.
Consider the calling chain: Main $$ \to $$ A1 $$ \to $$ A2 $$ \to $$ A21 $$ \to $$ A1
The correct set of activation records along with their access links is given by
A
GATE CSE 2012 Programming Languages - Function and Recursion Question 18 English Option 1
B
GATE CSE 2012 Programming Languages - Function and Recursion Question 18 English Option 2
C
GATE CSE 2012 Programming Languages - Function and Recursion Question 18 English Option 3
D
GATE CSE 2012 Programming Languages - Function and Recursion Question 18 English Option 4
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12