🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित छद्म कोड का आउटपुट क्या होगा?

What will be the output of the following pseudo-code ?

Integer a
Set a = 5
do
   print a - 2
              a = a- 1
while (a not equals 0)
end while
A)
B)
C)
D)

Explanation:

Let's break it down quickly:

  1. Initial value: a = 5.
  2. In each loop iteration:
    • Prints a - 2.
    • Decreases a by 1.
  3. The loop stops when a becomes 0.

Iterations:

  • First: prints 5 - 2 = 3, a becomes 4.
  • Second: prints 4 - 2 = 2, a becomes 3.
  • Third: prints 3 - 2 = 1, a becomes 2.
  • Fourth: prints 2 - 2 = 0, a becomes 1.
  • Fifth: prints 1 - 2 = -1, a becomes 0.

The loop stops when a = 0.

Output:

3 2 1 0 -1

So the correct answer is:
(D) None of these

Latest Updates