1
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider the following code fragment:
if (fork() == 0)
{
   a = a + 5;
   printf("%d, %d \n", a, &a);
}
else
{
   a = a - 5;
   printf ("%d, %d \n", a, &a);
}

Let $$u,v$$ be the values printed by the parent process, and $$x,y$$ be the values printed by the child process. Which one of the following is TRUE?
A
$$u=x+10$$ and $$v=y$$
B
$$u=x+10$$ and $$v \ne y$$
C
$$u+10=x$$ and $$v=y$$
D
$$u+10=x$$ and $$v \ne y$$
2
GATE CSE 2005
MCQ (Single Correct Answer)
+1
-0.3
What does the following C statement declare?
int (*f)(int *);
A
A function that takes an integer pointer as argument and returns an integer
B
A function that takes an integer as argument and returns an integer pointer
C
A pointer to a function that takes an integer pointer as argument and returns an integer
D
A function that takes an integer pointer as argument and returns a function pointer
3
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
double foo(double); /* Line 1 */
int main () {
  double da, db;
  //input da
  db = foo(da);
}
double foo(double a){
  return a;
}
The above code compiled without any error or warning. If Line 1 is deleted, the above code will show:
A
no compile warning or error
B
some compiler-warnings not leading to unintended results
C
some compiler-warnings due to type-mismatch eventually leading to unintended results
D
compiler errors
4
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
void foo (int n, int sum) {
  int k = 0, j = 0;
  if(n==0) return;
  k=n%10; j = n /10;
  sum = sum + k;
  foo(j, sum);
  printf("%d",k);
}
int main () {
  int a = 2048, sum = 0;
  foo(a, sum);
  printf("%d\n", sum);
}
What does the above program print?
A
8, 4, 0, 2, 14
B
8, 4, 0, 2, 0
C
2, 0, 4, 8, 14
D
2, 0, 4, 8, 0
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