Top

Discussion

What is the output of the following program?

#include

void swap(int m, int n)
{
   int x = m;
   
   m = n;
   n = x;
}
main()
{
   int x=5, y=3;

   swap(x,y);
   printf("%d %d", x, y);
}

 

  • A.3 5
  • B.5 3
  • C.5 5
  • D.Compile error

Answer: B

5 3, call by value mechanism can’t alter actual arguments.

No comment is present. Be the first to comment.
Loading…

Post your comment