34 Introduction to Computational Modeling
Every argument in the function call must be consistent with the corresponding
parameter declaration in the function definition. The following example shows the
definition of function squared that includes one parameter declaration, p, and returns
the value of local variable, res.
double squared (double p) {
double res;
res = p
*
p;
return res;
}
Listing 3.1 shows a short but complete program in C. Line 7 is the function
prototype for function squared and the function is called in line 14 with argument
x. The function definition of this function has only one parameter declaration, so the
function is called with one argument. It computes the square of the argument value,
which is the value of variable x and is used as ...