Open In App

Capgemini | Pseudocode Questions | Question 12

Predict the output of the following pseudo-code 

Integer x = 1, y = 2, z = 3 
x = y + z 
z = x – y 
z = z + x 
z = y + z 
y = y + z 
Print x, y, z

(A)

1 2 3 



(B)

4 6 8



(C)

5 12 10

(D)

8 6 10

Answer: (C)
Explanation:

Value of x is y + z = 2 + 3 = 5 
Value of z changes to x – y = 5 – 2 = 3 then z= z + x = 3 + 5 = 8 then z = y + z = 2 + 8 = 10 then y = y + z = 2 + 10 = 12 

Thus x = 5, y = 12, z = 10

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

Article Tags :
Uncategorized