Question 132

What is the output? void swap(int a, int b) {

What is the output? void swap(int a, int b) { int t = a; a = b; b = t; } int x = 1, y = 2; swap(x, y); printf("%d %d", x, y);
  1. A2 1
  2. B2 2
  3. C1 1
  4. D1 2
Show answerHide answer

Correct answer: (D) 1 2

Explanation

Call by value swaps only the local copies.

From DSSSB TGT Computer Science Full Mock Test 3

This is question 132 of DSSSB TGT Computer Science Full Mock Test 3. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.