निम्नलिखित छद्म कोड का आउटपुट क्या होगा?
What will be the output of the following pseudo-code ?
Integer a
Set a = 4
Do
print a + 2
a = a- 1
while (a not equals 0)
end while
A)
B)
C)
D)
Explanation:
Sure!
- The loop starts with
a = 4
and printsa + 2
. - In each iteration,
a
decreases by 1 untila
reaches 0. - The printed values are:
6 (4 + 2)
,5 (3 + 2)
,4 (2 + 2)
, and3 (1 + 2)
.
Answer: (B) 6 5 4 3.