returnstatement and no return value.
voidtype: We use this type when a subprogram has no return value. That means that we don't intend to and can't use the identifier
f_and_dfin an arithmetic expression. Notice that in the main program the calling statement has only the subprogram name and its arguments - it is not an assignment statement or an arithmetic expression.
doubleto receive the output from the subprogram. The ampersands
&in front of the subprogram arguments mean that we are handing the subprogram "pointers to'' or ``addresses of'' the two variables. In expressions an ampersand is a ``pointer to'' or ``address of'' operator. The
double *in the function definition declares that
fpis a "pointer to a double". The same is true for
dfdxp. So the argument types supplied in the calling statement match the declared arguments in the subprogram definition, as required. In the assignment statements the
*dfdxpcause the compiler to assign the computed values of the function and derivative to
dfdxin the main program, where they are subsequently used to update
pnew. We say the asterisk "dereferences" the pointer. Putting just
fpon the lhs would change the value of the pointer itself (and in this case we would get a compiler warning). With the dereferencing asterisk the rhs value is placed in memory at the address given by
x(subprogram) = x(main program); fp = &f; dfdxp = &dfdx;