Function and Recursion
A function is a grouping of statements that are created to do a particular job. Modules are required when a group of statements are frequently used by other distinct code. These are called Sub-Program.
Together, they referred to as Modular Programming.
Advantages:
They are divided into two types:
Together, they referred to as Modular Programming.
Advantages:
- An easily comprehensible top-down design
- Can be done by more than one developers
- Easy to debug
- Modifications can be done without affecting the overall code
- Easier to document
- Library function, a standard function provided by the code compiler
- User-defined function, a self defined function
- Local Identifier, which are declared in the function and are limited to the functions
- Global Identifier, which are declared outside the function, can be re-declared in the function, and can be reached from anywhere in the program
- Error rates increase
- Difficult to debug
- Low Data Exclusivity
They are divided into two types:
- By-Value Parameters, that send value to other modules
- By-Location Parameters, that send address to other modules
- Base Case, which is the return value
- Reduction Step, a series of input converging on the base case
- More memory consumption
- Takes longer time
Comments
Post a Comment