Consider the following C function void swap ( int x, int y ) { int tmp; tmp =…

ISRO Scientist/Engineer SC · May 2017 · Computer ScienceGATE · 2004 · CS

Consider the following C function

void swap ( int x, int y )
{
int tmp;
tmp = x;
x= y;
y = tmp;
}

In order to exchange the values of two variables a and b:

  1. A.

    Call swap (a, b)

  2. B.

    Call swap (&a, &b)

  3. C.

    swap(a, b) cannot be used as it does not return any value

  4. D.

    swap(a, b) cannot be used as the parameters passed by value

Attempted by 1227 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…