Get Started. It's Free
or sign up with your email address
Rocket clouds

1. Definition

1.1. A block of instructions that carry out particular task

2. Types of functions

2.1. 1) Built-in functions

2.1.1. Functions that already built by C++ compiler designer

2.1.2. Predefined by producer of a compiler (C++) and stored in header file (.h files) called libraries

2.1.3. Example : iomanip.h , math.h

2.2. 2) User-defined functions

2.2.1. Function designed, written or defined by programmers

2.2.2. Must be called in order to execute the statements contained in its definition

2.2.3. 3 requirements Function prototype Placed after header file and before main ( ) function Function call Placed within body of main ( ) function Function definiton Description or definition of what each function does

2.2.4. 2 categories Value-returning function Void function

2.2.5. Types of UDF No parameter and no return value No parameter but return value Parameter but no return value Parameter and return value Parameter and return more than one value

3. Local & Global Variable

3.1. Local Variable

3.1.1. Declared within a function and accessible only within that function

3.2. Global Variable

3.2.1. Declared before main function and accessible by all modules in the program

4. Parameter List

4.1. Pass information between main program and function

4.2. 2 types

4.2.1. Formal Parameter A variable declared in the function heading

4.2.2. Actual Parameter A variable or expression listed in a call to a function

5. Parameter Passing

5.1. Passing Value

5.1.1. declaration : int x;

5.1.2. cannot change actual parameter

5.1.3. constant, variable expression

5.1.4. duplicate actual parameter

5.1.5. read-only

5.1.6. local variable

5.2. Passing Reference

5.2.1. declaration : int &x;

5.2.2. can change actual parameter

5.2.3. variable

5.2.4. synonym for the actual parameter

5.2.5. read-write

5.2.6. local reference