Practice

AddOn BYREF Accumulator

MEDIUMProcedures & Functions6 marks

Write procedure AddOn(BYREF Total, BYVAL Amount) that adds Amount onto Total. Because Total is passed BYREF, the caller's variable must change.

The main program reads a starting total and how many amounts to add, then reads that many amounts, calling AddOn each time. Output the final total.

Input: Start, count, then that many integers. Output: The accumulated total.

Example:

Input:  10
        3
        4
        5
        6
Output: 25
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Three additions
Inputs: 10, 3, 4, 5, 6
Expected: 25
Test 2: One addition from zero
Inputs: 0, 1, 8
Expected: 8