1
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
What is printed by the following C program?
#include < stdio.h >
int f(int x, int *py, int **ppz)
{
   int y, z;
  **ppz += 1; 
   z  = **ppz;
  *py += 2;
   y = *py;
   x += 3;
   return x + y + z;
}
 
void main()
{
   int c, *b, **a;
   c = 4;
   b = &c;
   a = &b; 
   printf( "%d", f(c,b,a));
   getchar();
}
A
18
B
19
C
21
D
22
2
GATE CSE 2006
MCQ (Single Correct Answer)
+2
-0.6
Consider this C code to swap two integers and these five statements:
void swap(int *px, int *py) 
{ 
    *px = *px - *py; 
    *py = *px + *py; 
    *px = *py - *px; 
}
S1: will generate a compilation error

S2: may generate a segmentation fault at runtime depending on the arguments passed

S3: correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the process

S4: implements the swap procedure correctly for some but not all valid input pointers

S5: may add or subtract integers and pointers.
A
S1
B
S2 and S3
C
S2 and S4
D
S2 and S5
3
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program segment:
char p[20];
char *s = "string";
int length = strlen(s);
for(i=0; i < length; i++)
  p[i] = s[length-i];
printf("%s",p);
The output of the program is
A
gnirts
B
string
C
gnirt
D
no output is printed
4
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
GATE CSE Subjects
Software Engineering
Web Technologies
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
CBSE
Class 12