Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE CS 2019 | Question 27

  • Difficulty Level : Easy
  • Last Updated : 17 Aug, 2021

Consider the following C program:




#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;
  
}

The value printed by program is __________ .

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


Answer: (A)

Explanation:




#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;
  
}

Initially 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
Recommended Articles
Page :

Start Your Coding Journey Now!