Open In App

Capgemini | Pseudocode Questions | Question 4

Integer x, y 
Set x = 15, y = 12 
y = x – 1 
do{ 
  Print x 
  x = y + (x – 2) 
} 
while(x < 40) 
end do while

(A)

14 26



(B)

15 27 39



(C)

27 39

(D)

15

Answer: (B)
Explanation:

Firstly variables x and y are initialized, then x and y are assigned values 15 and 12 respectively.
Then Assign y the value of x – 1.
print x i.e 15
do while loop runs till x is less than 40 assign x with the value of y + x – 2 and print x
The order in which value of x changes is 15 then 27(14 + 15 – 2) then 39(14 + 27 – 2), then 51(14 + 39 – 2) and the do while loop terminates.

The final series obtained is 15 27 39

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :
Uncategorized