GATE CS 2024 Set 1 | Question 48

Programming & Data Structures › Functions · MSQ · 2 marks · Answer: B, D

  1. Question 48Programming & Data Structuresmsq2 marks
    runs for(i=0;i<y;i++) x = x+x+y; and returns . Which statements is/are TRUE?
    • A.
      x=20,y=10 -> return > 2^20
    • B.
      x=20,y=20 -> return > 2^20
      ✓
    • C.
      x=20,y=10 -> return < 2^10
    • D.
      x=10,y=20 -> return > 2^20
      ✓

    Answer: B, D

    Solution

    Answer: (B) and (D) Each iteration does , roughly doubling . After iterations grows like . - : factor ; starting from 20, result is around –, which is but not . So (A) false, (C) false. - : factor , so the result far exceeds -> (B) true; same for -> (D) true.

More GATE PYQ on Functions

All GATE CS Programming & Data Structures PYQ →

Attempt GATE CS 2024 Set 1 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →