Skip to content
Related Articles

Related Articles

GATE | GATE-CS-2004 | Question 2
  • Last Updated : 15 Sep, 2014

Consider the following C function




void swap (int a, int b)
{
   int temp;
   temp = a;
   a = b;
   b = temp;
}


In order to exchange the values of two variables x and y.
(A) Call swap (x, y)
(B) Call swap (&x, &y)
(C) swap(x,y) cannot be used as it does not return any value
(D) swap(x,y) cannot be used as the parameters are passed by value


Answer: (D)

Explanation: See question 3 of https://www.geeksforgeeks.org/c-language-set-2/

Quiz of this Question

sudo-gate-course

My Personal Notes arrow_drop_up
Recommended Articles
Page :