Practice

Swap Values Using BYREF

EASYProcedures & Functions5 marks

Write and use a procedure that swaps two integer variables.

The procedure parameters must use BYREF so the caller's variables are changed. Output the two values after the procedure call.

Input: Two integers. Output: The values in swapped order, one per line.

Example:

Input:  4
        9
Output: 9
        4
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Different positive values
Inputs: 4, 9
Expected: 9 4
Test 2: Negative and positive
Inputs: -3, 8
Expected: 8 -3