Boss: update the price in place
Level 3: Parameters. The procedure has to change the caller’s price. The rate is only an input. That is BYREF for one parameter and by value for the other.
Write ApplyDiscount(BYREF Price, Rate). It sets
Price ← Price × (100 − Rate) DIV 100
Read a price and a rate, call the procedure, and output the new price.
Example: 200 then 10 → 180. Use DIV, not /, so the result is an integer.
- Previous: Reference or copy?
- Next: Write a record, read it back
- AS & A Level Path