1
GATE CSE 2003
MCQ (Single Correct Answer)
+2
-0.6
Consider the C program shown below.
#include < stdio.h >
#define print(x) printf("%d ", x)
int x;
void Q(int z) {
   z += x; print(z);
}
void P(int *y) {
   int x = *y+2;
   Q(x); *y = x-1;
   print(x);
}
main(void) {
   x = 5;
   P(&x);
   print(x);
}
The output of this program is
A
12 7 6
B
22 12 11
C
14 6 6
D
7 6 6
2
GATE CSE 2001
MCQ (Single Correct Answer)
+2
-0.6
Consider the following three C functions:
[P1] int*g(void)
     {
       int x=10;
       return(&x);
     }
[P2] int*g(void)
      {
        int *px;
       *px = 10;
        return px;
      }
[P3] int*g(void)
     {
       int *px
       px =(int*)malloc (size of (int));
       *px = 10;
       return px;
     }
Which of the above three functions are likely to cause problems with pointers?
A
Only P3
B
Only P1 and P3
C
Only P1 and P2
D
P1, P2 and P3
GATE CSE Subjects
Software Engineering
Web Technologies
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