Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-CS-2016 (Set 1) | Question 25

  • Last Updated : 12 Aug, 2021

Consider the following C program.




#include<stdio.h>
void mystery(int *ptra, int *ptrb) 
{
   int *temp;
   temp = ptrb;
   ptrb = ptra;
   ptra = temp;
}
int main() 
{
    int a=2016, b=0, c=4, d=42;
    mystery(&a, &b);
    if (a < c)
       mystery(&c, &a);
    mystery(&a, &d);
    printf("%d\n", a);
}

The output of the program _____________

 
Note : This question was asked as Numerical Answer Type.

(A) 2016
(B) 0
(C) 4
(D) 8


Answer: (A)

Explanation: Note that a and d are not swapped as the function mystery() doesn’t change values, but pointers which are local to the function.



Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :