application of stacks.
i have this question..
show the state of the stack and the value of each variable after execution of the following statements.
let A=5, B=3, C=7
push A onto stack
push C*C onto stack
pop item fron the stack and store in B
push B+A onto stack
pop item from the stack and store in A
pop item for the stacj and sotore in B
-------------------------------------
what will be the value of B after C*C is popped out of the stack?? will the predefined value of B be overwritten?? and what if B is pushed onto the stack, will the value of the pushed B be the value of the result of C*C??
for example..
this???
push A onto stack = 5
push C*C onto stack = 49
pop item fron the stack and store in B = B=49
push B+A onto stack = 49+5=54
pop item from the stack and store in A = A=54
pop item for the stacj and sotore in B = B=5
??????????????????????
or this??
push A onto stack = 5
push C*C onto stack = 7*7=49
pop item fron the stack and store in B = B=49
push B+A onto stack = 3+5=8
pop item from the stack and store in A = A=8
pop item for the stacj and sotore in B = B=5
???????????????????/
HELP
scias23
Junior Poster in Training
69 posts since Jan 2009
Reputation Points: 11
Solved Threads: 0
When you store something in B, that means the predefined value will be overwritten.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
Anyway, your first example (where A gets assigned 54) is perfectly right.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177