August 1997
AP207: ADVANCED PROGRAMMING TECHNIQUES

QUESTION 2

Total Marks: 20 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 2

2. (a) Explain the similarities and differences between a function and a procedure. [5]
(b) Identify the differences between call-by-value and call-by-reference parameter passing. [2]
(c) This question is concerned with the implementation of routines that analyse a simple "pass mark" database. The database can contain at most ClassSize records. The various database types you should use in your routines are shown below.

Const ClassSize = 20;
Type MarkRange = 0 . . 100;
DatabaseType = Array [1 . . ClassSize] of MarkRange;
(i) Define a function averageMark that takes two arguments: a pass mark database; and an integer n (you can assume that n < ClassSize) that identifies that the first n elements in the database contain student marks. The result from the function should be a Real that represents the average mark. [6]
(ii) Define a procedure passFail that takes as its arguments a database of marks and an integer n (you can assume that n < ClassSize) that identifies the number of pass marks in the database, and returns two results: the number of candidates that obtained a pass (i.e., a pass mark > 50); and those that failed. [7]