GATE | GATE CS 2019 | Question 27

Consider the following C program:

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
  int jumble(int x, int y) {
    x = 2 * x + y;
    return x;
  }
int main() {
  int x = 2, y = 5;
  y = jumble(y, x);
  x = jumble(y, x);
  printf("%d\n", x);
  return 0;
  
}

chevron_right


The value printed by program is __________ .

Note: This was Numerical Type question.
(A) 26
(B) 2
(C) 5
(D) 12


Answer: (A)

Explanation:



filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
  int jumble(int x, int y) {
    x = 2 * x + y;
    return x;
  }
int main() {
  int x = 2, y = 5;
  y = jumble(y, x);
  x = jumble(y, x);
  printf("%d\n", x);
  return 0;
  
}

chevron_right


Intially x = 2, y = 5;
jumble (5, 2) is called and y will updated as 12
jumble (12, 2) is called and x will updated as 26
Final value of x = 26

So, option (A) is correct.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.