Computer Science
Programming and reasoning
- 1.
A function receives integer x by value, assigns x=x+1 and returns nothing. The caller's variable n was 5. State n after the call and explain why.
[3 marks] · no calculator - 2.
Distinguish validation from verification for an entered date of birth, giving one example of each.
[3 marks] · no calculator - 3.
Trace: total=0; FOR i=1 TO 4 inclusive: IF i mod 2=0 THEN total=total+i ELSE total=total-1. Give total after each iteration.
[3 marks] · no calculator - 4.
A recursive function F(n) returns 1 if n=0, otherwise returns n*F(n-1), for integer n>=0. Trace F(4), and explain the base case's role.
[3 marks] · no calculator - 5.
A function accepts integer ages from 16 through 120 inclusive. Design a minimal boundary-focused test set that checks both acceptance boundaries and adjacent rejection, plus one distinct type-error case; state expected outcomes.
[4 marks] · no calculator - 6.
Two tasks both execute read counter; add 1 locally; write counter. Starting at zero, show an interleaving ending at 1 rather than 2, and propose a synchronisation remedy with its scope.
[4 marks] · no calculator
Marking points are indicative, not an official mark scheme. Accept equivalent valid methods and supported interpretations that address the task; award each mark once without requiring the model wording.