Learning Objectives
- At the end of this topic, you will be able to:
- Explain the concept of modular programming
- List types of functions
- Declare and call a function
- Describe the working of a function
- Identify local and global variables
- Explain how a function call mechanism is supported by the function call stack and activation records
- Identify function prototype
- List and explain storage classes
- State scope rules
- Discuss recursion
- Give an example of ‘C’ programs using functions
- List and explain the pre-processor directives
Modular programming
Modular
programming is a programming style that breaks down a task into modules, each
of which accomplishes one task and contains all the source code and variables
needed to finish that task.
By
segmenting the program into modules, we can isolate the source of the program
errors to a small segment of the code
Modular
programming-Why?
- Is a solution to the problem of very large programs that are difficult to debug
- Makes development faster
- Easier to debug, update and modify
- Leads to a structured approach, as a complex problem can be broken into simpler tasks
- One module may use another module, to achieve its purpose
- Each module works independently of another
- Encourages re-use of code