Modular Programming/What is modular programming? Explain.
Modular programming
Modular programming is defined as the programming technique that is used to divide a program into various sections known as modules to make a task easier. The advantages of dividing a program into modules i.e multiple sets of tasks can be done in a single program.
For example: In a single program we use incorporate addition, subtraction, multiplication, and division all at the same time using modules.
Module
A module can be defined as the section of a program that is designed to perform a specific task.
For Example: In a program that calculates area the module that calculates the area of a rectangle area of a square can be created.
Main Module
The main module can be defined as the main component of a program that handles the job of calling other sub-modules and running a program. This is similar to a CEO of an office that provides and designates operations to other staff in the office.
Sub Module or Producers
They are the small modules that are incorporated in the main module to add various features to the same program.
For Example: In a program that says calculator sub-modules such as addition, subtraction, division, and multiplication can be added to add multiple numbers of services, etc.
The modules or procedures can be mainly divided into two types in Q-BASIC.
They are:
A. Sub-procedure
B. Function procedure
A. Sub-procedure
This is a module or sub-procedure which can be called by the main module to perform a particular task. The parameters of this procedure can be defined in the procedure declaration part and the same parameters can be passed on to the submodule by the main module using calling features of the subprocedure.
The basic structure of the subprocedure is given below:
MAIN MODULE
Declare sub-sub-procedure- name (parameters)- Declaration
.....
CALL Sub procedure name (Arguments)...... call
SUBMODULE
Sub sub-procedure-name (parameters)
{
code or statements
}
END SUB
view for more results...