Lecture 4 Objectives
At the end of today's class you should
KNOW:
- What is meant by each of the following terms: function definition,
function call, function header, function body, function prototype, return type,
parameter, argument, library function, user-defined function, pre-condition,
post-condition, stub
- How to illustrate the inputs to and outputs from a function using a
"black box"
BE ABLE TO:
- Write a program that calls a C library function
- Given a description for a function, draw the "black box" for that function
- Given a description for a function, write pre- and post-conditions for
the function
- Given a function prototype, write a syntactically correct function call
- Given a function prototype, write the function as a stub
Sample Exam Question:
Given this function description:
The function named Volume uses a char called shape
and two floats called dimension1 and dimension2
to determine the volume of a geometric shape. It is assumed that upon
entry to the function, the value of shape is either 'C', 'Y',
or 'T' (for cone, cylinder, or torus). It is also assumed that the
values of dimension1 and dimension2 are greater than 0.0.
- Draw the function as a "black box" with inputs and outputs shown as
labelled arrows. Indicate the data type associated with each arrow.
- Write a prototype for this function.
- Write a pre-condition for this function.
- Write the function as a stub.