Value assignments

h4me (2)
Suppose x, y, and z are int variables. What value is assigned to each of these variables after the last statement executes?

x = 4; y = 11;
z = y - 2 * x;
x = z + y;
y = x + 5 * z;
w = x - y + 2 * z;
x = y + w - x;
-w;
Disch (8623)
It's a pretty straightforward question. Just step through each line and keep track of what x,y, and z are after each line executes.
randisking (37)
Silly homework question is silly. This isn't hard, if you want to track it in a compiler though you can create a program in c++ with this code, set a watch for each variable and step through the program one step at a time. But this is simple, you could simply do it with a piece of paper.
h4me (2)
Thank you both for your help.
Registered users can post here. Sign in or register to post.