GATE CSE 2024 Session 1 Q48: Return value bounds of a loop computing x = x + x + y
- Programming and Data Structures
- 2 marks
- MSQ
- No negative marking
Question
Consider the following C function definition.
int f(int x, int y) {
for (int i=0; i<y; i++) {
x=x+x+y;
}
return x;
}Which of the following statements is/are TRUE about the above function?
Try it: multiple select: one or more correct options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation
Answer: B, D (official GATE 2024 final answer key)
Concept used: The update repeated times gives a closed form.
First step: Show doubles each iteration, so the result is .
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2024 Session 1 CS question paper and final answer key, organised by IISc Bangalore. 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