Reasoning Class 9 Other

Asked by GIANSH GUPTA KHUNDKER · BIRLA BRAINIACS

Consider the following pseudo-algorithm used to compute a value:
1. Start with X = 5, Y = 2, Z = 0.
2. Loop start: If X > 0:
• Z = Z + Y
• X = X - 1
• Go back to Loop start.
3. If X is not greater than 0, print Z.
What value is printed at the end of execution?

Answer as guest — Start Free Practice Test to earn Practice PointsHow to earn pointsAsk a question+3Answer a question+1Someone answers yours+1Your Q gets upvoted+1Pioneer bonus (first 5)+51 point = ₹1 discount on purchases, ask questions & climb the leaderboard!
Show answer and explanation

Answer: C. 10

Answer: (C) 10
Explanation:
• This loop acts as a multiplication mechanism (X × Y).
• The loop runs exactly 5 times because X starts at 5 and decreases by 1 each iteration (5 → 4 → 3 → 2 → 1 → 0).
• In each of the 5 runs, Y (which is 2) is added to Z.
• Total value of \(Z = 2 + 2 + 2 + 2 + 2 = \mathbf{10}\).

Answering after opening this box earns no Practice Points.

70%