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=_____."

Recommended Answers

All 8 Replies

I think I'm missing something ... The statement "set x = x + 20" *is* pseudocode?

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.

With that being said, how would i annotate that in pseodocode?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.