Chapter 3
Modular Programming
Creating user defined functions
➢ C++ provides a mechanism similar to any other programming language that
would create modules of the program called functions.
➢ the main () function - responsible for calling other functions although any
function can call any other function.
- Avoid task duplication
- Make large tasks manageable
o functionPrototype - tells the compiler what the function has,
the type of return value and the number of function arguments.
o returnDataType - be given back once the function would
finish its operation.
o functionName - identifier used so that the function can be
invoked (or called); begin a function name with an action word.
o parameterList - contain the information that would be given to
function once it is invoked.
o Statements - executable task bounded within curly braces.
o Return - actual value that is returned as a result of the process
given by the function.
• Void function - nullify any form of data type with its corresponding value that is
returned from a function.