View worked solution
Answer: 80
Each assignment statement is executed at the machine level as three instructions:
- Read: Load into a local register .
- Modify: .
- Write: Store back to .
To find the minimum and maximum possible final values of (initialized to ):
1. Minimum Value ():
We want the decrement operation of () to overwrite the increments of and :
- reads ().
- and execute completely in sequence, updating to ().
- resumes, decrements its register (), and writes .
Thus, the minimum value is .
2. Maximum Value ():
We want the increment of () to overwrite the decrement of ():
- executes completely, updating to .
- reads ().
- reads ().
- decrements and writes .
- resumes, increments its register (), and writes .
Thus, the maximum value is .
The required difference is:
Free practice · Your answers on this page are not saved.
