Consider the following C function C void swap (int a, int b) { int temp; temp…

Consider the following C function

C

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.

  1. A.

    Call swap (x, y)

  2. B.

    Call swap (&x, &y)

  3. C.

    swap(x,y) cannot be used as it does not return any value

  4. D.

    swap(x,y) cannot be used as the parameters are passed by value

Attempted by 1075 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…