GATE | Gate IT 2008 | Question 48
Consider the C program below. What does it print?
# include <stdio.h> # define swapl (a, b) tmp = a; a = b; b = tmp void swap2 ( int a, int b) { int tmp; tmp = a; a = b; b = tmp; } void swap3 (int*a, int*b) { int tmp; tmp = *a; *a = *b; *b = tmp; } int main () { int num1 = 5, num2 = 4, tmp; if (num1 < num2) {swap1 (num1, num2);} if (num1 < num2) {swap2 (num1 + 1, num2);} if (num1 >= num2) {swap3 (&num1;, &num2;);} printf ("%d, %d", num1, num2); } /* Add code here. Remove these lines if not writing code */ |
chevron_right
filter_none
(A) 5, 5
(B) 5, 4
(C) 4, 5
(D) 4, 4
Answer: (C)
Explanation: “if (num1 > = num2) {swap3 (&num1, &num2);}” statement is true, so call by reference will be performed.
Quiz of this Question
Recommended Posts:
- GATE | Gate IT 2008 | Question 42
- GATE | Gate IT 2008 | Question 23
- GATE | Gate IT 2008 | Question 22
- GATE | Gate IT 2008 | Question 21
- GATE | Gate IT 2008 | Question 20
- GATE | Gate IT 2008 | Question 19
- GATE | Gate IT 2008 | Question 18
- GATE | Gate IT 2008 | Question 17
- GATE | Gate IT 2008 | Question 16
- GATE | Gate IT 2008 | Question 15
- GATE | Gate IT 2008 | Question 14
- GATE | Gate IT 2008 | Question 13
- GATE | Gate IT 2008 | Question 24
- GATE | Gate IT 2008 | Question 25
- GATE | Gate IT 2008 | Question 26
Improved By : GehadAhmed



