GATE CSE 2019 Q28: C program with jumble(x, y) = 2x + y called twice: value printed
- Programming and Data Structures
- 1 mark
- NAT
- No negative marking
Syllabus topic: Programming in C
Question
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 the program is ________.
Try it: numerical answer: type the value
Numerical answer. No negative marking.
Show answer and explanation
Answer: 26 (official GATE 2019 final answer key)
Concept used: C passes arguments by value: changes to parameters inside a function do not affect the caller's variables, only the returned value is used.
First step: Note the swapped argument order in the call jumble(y,x), compute the new y from the first call, then use it in the second call.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Programming in C
Every PYQ on this topic →Share this question
Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key
More Programming and Data Structures PYQs
- 2026 Session 1 · Q23Non-leaf indices in a 1-indexed binary heap with n odd
- 2026 Session 1 · Q24Empty slots after linear-probing inserts with h(x) = (x+7) mod 11
- 2026 Session 1 · Q33Maximum height of a full binary tree with 23 nodes
- 2026 Session 1 · Q34Output of a C function with a shadowed block variable
- 2026 Session 1 · Q39Recursive length of a non-empty singly linked list
- 2026 Session 1 · Q40Third insertion that can never yield a complete BST of 1..15