OCT/NOV 2021
SOLUTIONS
QUESTION 1
1.1: newval = 2
1.2: a = 13
1.3: Output: 23
, QUESTION 2
2.1: The code calculates the sum of numbers from 0 to 5.
2.2: The code counts how many non-zero elements are in the numbers array.
---
QUESTION 3
Initial values are: a = 2, count = 0.
After the loop, a = 18, output is 18.
---
QUESTION 4
4.1: int registrants; float amountOwed;
4.2: cin >> registrants; if (registrants <= 0) cout << "Error: Invalid number of
registrants.";
4.3:
cpp
if (registrants >= 1 && registrants <= 4) amountOwed = registrants * 100;
else if (registrants <= 10) amountOwed = registrants * 80;
else amountOwed = registrants * 60;
cout << "Amount owed: " << amountOwed;
---