August
1999 QUESTION 5 Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
(a) | Explain what an expression is in C.
|
[2] |
(b) | An assignment is one kind of
expression in C. Explain what is meant by the term assignment.
|
[2] |
(c) | Write a function, called RunningTotal, which
takes on value parameter, x, and returns a running total of all the values passed to the
function during the execution of the program so far.
|
[4] |
(d) | Using a switch statement, write a function
foobar, which takes a character as a parameter. If the character passed in is
"a" or "A", the function should exit immediately. If the
character passed in is "b" or "B", nothing should happen. For any
other value, the function should cause the program to exit immediately with a
value of -1.
|
[6] |
(e) | Write a function called fun that prompts the
user to enter a number in the range 0-9. If the number entered is outside the required
range, the prompt to the user should be repeated, otherwise the function will return the
integer selected by the user. |
[6] |