Jan/Feb 2024
exam:
SOLUTIONS
Question 1:
1.1) newval = 6
, 1.2) a = 12
1.3) cout << findValue(3) will output 23
---
Question 2:
2.1) The code calculates the sum of integers from 0 to 5 and stores it in variable
s.
2.2) The code counts how many non-zero values are in the array numbers[] and
stores the count in c.
---
Question 3:
The variable diagram would show the following changes at each step:
Lin a cou value
e nt P
3 2 - 6
5-6 5 2 6
7-8 9 4 6
7-8 1 6 6
4
Final output: a = 14
---
Question 4:
4.1) Declare variables:
cpp
int registrants = 0;
float amountOwed = 0;