EXAM PACK
FOR ASSISTANCE WITH THIS MODULE +27 67 171 1739
, ICT3612/104/1/2018
Example of an examination paper
Question 1 4 marks
Code, then use a simple function that contains one required and one default parameter.
Question 2 10 marks
2.1 Consider the following function:
<?php
function subtract($first_number, $second_number){
$result = $first_number - $second_number;
return $result;
}
?>
Define appropriate variables, and then use them with the function so that the following
sentence is printed:
The result of the calculation is -76. (6)
2.2 Consider the following function that works with a variable-length parameter list:
<?php
function dynamic_args() {
for($i = 0 ; $i < func_num_args(); $i++) {
echo "Argument $i = ".func_get_arg($i)."<br />";
}
}
?>
i. Use the function to produce the following lines:
Argument 0 = a
Argument 1 = b (2)
ii. Use the function again, but this time the following lines must be produced:
Argument 0 = a
Argument 1 = b
Argument 2 = c
Argument 3 = d
Argument 4 = e (2)
Question 3 28 marks
3.1 Create and use a simple class containing a single method that will produce the
following output:
Hello Felicia! (4)
3