I have been given the following question in one of my classes, and i know it is probably extremely simple, i am just very thick. Can some one explain to me the steps to work out this problem.

"Starting with the following initial values, specify the value of each variable at the end. (in pseudocode)

x=30, y=20, z=10

Set X=x+20

X=_____, Y=_____, and Z=_____."

10 Years
Discussion Span
Last Post by WaltP

I have no idea, that is just the question that was posed to me in an assignment word for word.


what do you think the answer is? If you have 30 apples and I give you 20 more then how many apples will you have? The answer is that simple.


Now that was simple enough, but how would "Set X=X+20" fit into that scenario, if X=10 how can 20+X=...10


I think you've not learnt the basics yet... First the value of LHS expression is evaluated and then it is assigned to the variable on RHS... So, first X+20 (50) is evaluated & then it (50) is assigned to X. The procedure simply results in incrementing the value of X by 20. Other values remain unchanged.


Just state in the pseudocode that x=x+20 results in incrementing the value of x by 20. Nothing else would be required.


Set X=x+20
Add 20 to X
Increment X by twenty
20 is added to X

In other words, any way you want to word it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.