Project ForgeSign up free
Programming in C
Programming Fundamentals
GATE 2019
Medium

Consider the following C program:

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 the program is

26

Explanation

y=jumble(y,x)=jumble(5,2): x_local=2×5+2=12, returns 12 — main's y becomes 12 (main's x still 2). x=jumble(y,x)=jumble(12,2): x_local=2×12+2=26, returns 26 — main's x becomes 26. Printed: 26.

Source: GATE CS 2019 (Set-2) (2019)

This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.

Start revising free