Programming in c++ Functions Dale/eems/Headington
1 Functions
Programming in C++ Chapter 7 Topics Writing a Program Using Functional Decomposition Writing a Void Function for a Task s Using Function Arguments and Parameters correctly Differences between Value Parameters and Reference Parameters s Using Local Variables in a Function Function Preconditions and Postconditions
2 Chapter 7 Topics ❖Writing a Program Using Functional Decomposition ❖Writing a Void Function for a Task ❖Using Function Arguments and Parameters correctly ❖Differences between Value Parameters and Reference Parameters ❖Using Local Variables in a Function ❖Function Preconditions and Postconditions
Programming in C++ Functions oevery C++ program must have a function called main program execution always begins with function main o any other functions are subprograms and must be called
3 Functions ❖every C++ program must have a function called main ❖program execution always begins with function main ❖any other functions are subprograms and must be called
Programming in C++ Function Call(Invocation One function calls another by using the name of the called function next to( enclosing an argument list A function call temporarily transfers control from the calling function to the called function
4 Function Call (Invocation) One function calls another by using the name of the called function next to ( ) enclosing an argument list. A function call temporarily transfers control from the calling function to the called function
Programming in C++ Function Call Syntax FunctionName( Argument List The argument list is a way for functions to communicate with each other by passing information y The argument list can contain 0, 1, or more arguments, separated by commas, depending on the function
5 FunctionName ( Argument List ); ➢ The argument list is a way for functions to communicate with each other by passing information. ➢ The argument list can contain 0, 1, or more arguments, separated by commas, depending on the function. Function Call Syntax