0% found this document useful (0 votes)
15 views

Modular Programming

Modular programming involves breaking large, complex programs into smaller, more manageable modules or procedures. There are two main types of procedures in QBASIC: sub procedures and function procedures. Sub procedures perform specific tasks without returning a value, while function procedures perform tasks and return a single value. Modular programming makes programs easier to design, test, understand, and modify by separating them into independent, reusable modules.

Uploaded by

Kalay Ro Son
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Modular Programming

Modular programming involves breaking large, complex programs into smaller, more manageable modules or procedures. There are two main types of procedures in QBASIC: sub procedures and function procedures. Sub procedures perform specific tasks without returning a value, while function procedures perform tasks and return a single value. Modular programming makes programs easier to design, test, understand, and modify by separating them into independent, reusable modules.

Uploaded by

Kalay Ro Son
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MODULAR PROGRAMMING PROCEDURE

Application file name of qbasic: QB.exe A small, logical and manageable functional part of
Extension file name of Qbasic: .bas program is known as procedure.
MODULAR PROGRAMMING
The process of breaking the large & complex programs There are two types of procedure in QBASIC there are
into small manageable part is called modular 1. SUB Procedure 2. Function Procedure
programming. SUB PROCEDURE
ADVANTAGES OF MODUALR PROGRAMMING A sub procedure is a small, logical and manageable
1. Different programmers can write different program functional part of program which perform specific
modules independently. action and does not return any value.
2. It is easy to design the code and test the program FEATURES OF SUB PROCEDURE
modules independently, 1. It does not return any value.
3. It is easy to understand and debug the program. 2. It is called by call keyword.
4. Modification in programs can be easily done. 3. It does not consider any data type.
5. It is possible to use single module in different places. 4. It can pass the parameter by both reference and value.
MODULE FUNCTION PROCEDURE
A small, logical and manageable program is called module. A function is a small, logical and manageable functional
Modules are divided into two parts: main module and part of program which perform specific action and returns
submodule. a single value to main module.
MAIN MODULE FEAUTRES OF FUNTION PROCEDURE
The top level controlling section or the entry point in 1. It returns value.
modular programming is called main module. 2. It can be called by expression or print statement.
SUB MODULE 3. It considers any data type.
Sub module is a program which is written under the main 4. It can pass the parameter by both reference and value.
module. There are two types of function. They are
A program may have one or more sub module under main 1. Library function or built in function
module. 2. User defined Function

Prepared By:- Roshan Acharya [email protected] SSCSS


1. LIBRARY FUNCTION value from the actual parameter. Formal parameter are
Library function are built in or readymade called parameter.
functions provided by QBASIC. Example: A formal parameter is always variable(s)
LEFT$, RIGHT$, MID$ etc
2. USER DEFINED FUNCTIUON Passing Arguments By Value Vs Passing Arguments
Function which is defined by the user according to the By Reference
need is called user defined function. Passing Arguments By Passing Arguments By
FUNCTION OF CALL STATEMENT Value Reference
The Function of CALL Statement is to transfer the control
to another procedure. When arguments are When arguments are
FUNCTION OF DECLARE STATEMENT passed by values it makes passed by reference the
The function of DECALRE statement is ti declare a duplicate copy of address of the variables
procedure such as SUB or FUNCTION in modular arguments and their values are passed to the
programming. are used directly in procedure.
PARAMETERS parameter.
Parameter are variables that will receive data or values It does not make any The change made in the
send to procedure. effect on values of procedure’s variable will
ARGUMENTS variables which are passed affect variables used at
Arguments are the values send to the procedures. to a procedure even they calling module.
ACTUAL or REAL PARAMETER are changed in the
Real or Actual parameter are arguments which are used to procedure.
pass real value of data to the procedure.
Actual parameter may be variables or constant values. To pass the argument by By default the value is
Actual or real parameter are called arguments. value, variable is enclosed passed by reference.
FORMAL PARAMETER in parenthesis.
Formal Parameter are the variables declared for data
types with DECLARE Statement inside the parenthesis.
Formal parameter are parameter which receives the
Prepared By:- Roshan Acharya [email protected] SSCSS
Local Variable Vs Global Variable SHARED
Local Variable Global Variable The SHARED statement is used to share variables of
Variables are declared Variables are declared main modules without passing them as parameters. It is
inside the procedure outside the procedure used in sub program.
COMMON SHARED
are called local are called global
The common shared statement is used to declares
variables. variables.
global variables for sharing between main module
Local variable are not Global variables are
and all sub program.
visible to other modules visible to other modules
It is used in main module.
or functions. or functions.
Why is large modules broken into small procedures?
Its value is protected Its value can be accessed
Large modules are broken into small procedure to
from outside from any procedure or
eliminate redundancy, for easier understanding, testing
interference and has no module. and debugging. Static Variable
effect on the variables
The variable which is declared by using “STATIC”
outside the procedures.
keyword is called static variable.
Sub Procedure Vs Function Procedure
Sub-Procedure Function Procedure ARRAY
1. Sub-procedure does not 1. Function Procedure must An array is a collection of multiple data element stored
return value. return a value. under a common variable name.
2. Sub-procedure called by 2. Function procedure Recursion
call keyword. is called by statement Recursion is a programming technique that allows
& expression method. the programmer to express in terms of themselves.
3. Sub-procedure name 3. Function procedure A subprogram or module that can call itself is called
does not accept data type. accept data type. recursion
LOOP
DIM SHARED A loop is a sequence of instruction that is continually
The DIM SHARED is used to define array or simple repeated until a certain condition is reached.
variables as global variables that allocates memory.
Prepared By:- Roshan Acharya [email protected] SSCSS
Variable
Variable is the location or address which store values.
There are two types of variables. They are
a. Numeric Variable For ex. A=23,B=45
b. String Variable. For ex. R$=”ROM” , C$=”School”

Prepared By:- Roshan Acharya [email protected] SSCSS

You might also like