- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatTutorial/B0120.cpp File Reference

`#include "MusimatTutorial.h"`

Go to the source code of this file.

## Functions
| MusimatTutorialSection (B0120)

## Function Documentation

MusimatTutorialSection | ( | B0120 |  | ) |

Definition at line 2 of file B0120.cpp.

    00002                               {
    00003 Print("*** B.1.20 Invoking Functions ***");
    00004 /*****************************************************************************
    00005
    00006 B.1.20 Invoking Functions
    00007
    00008 We had two situations where the function euclid() was followed by a list of arguments, once
    00009 where it was defined, and another where it was invoked. The arguments associated with the def-
    00010 inition of euclid() are called its formal arguments. They are Integer m and Integer n.
    00011 The values associated with its invocation (integers 91 and 416) are called its actual arguments.
    00012 A function will have only one set of formal arguments that appear where the function is defined.
    00013 It will have as many sets of actual arguments as there are invocations of the function in a program.
    00014
    00015 When a function is invoked, three things happen:
    00016
    00017 1. The values of the actual arguments are copied to the corresponding formal arguments.
    00018
    00019 If an actual argument is a constant, its value is simply copied to the corresponding formal argu-
    00020 ment. Example: Print(3) copies 3 to the formal argument for Print().
    00021
    00022 If an actual argument is a variable, its value is copied to the corresponding formal argument. Exam-
    00023 ple: Integer a = 3; Print(a) copies the value of a (which is 3) to the formal argument for
    00024 Print().
    00025
    00026 If an actual argument is another function, that function is evaluated first, and its return value
    00027 replaces the function. Example: For the statement Print(euclid(91, 416)), first
    00028 euclid(91, 416) is evaluated, and the result (which is 13) is substituted in its place. So the
    00029 statement becomes Print(13). Finally, the 13 is copied to the corresponding formal argument
    00030 of the Print() function.
    00031
    00032 2. The body of the function is executed using the values copied to the formal arguments in the
    00033 first step.
    00034
    00035 3. The return value of the function is substituted for the function call in the enclosing program.
    00036
    00037 *****************************************************************************/
    00038 }}