SlideShare a Scribd company logo
MODULAR PROGRAMMING
Prepared by: Roshan Maharjan
Modular Programming
OVERVIEW
■ Modular programming is a technique of developing software by
separating the functionality of a program into independent
interchangeable modules that are combined together to get the final
working software.
■ Modular programming is a technique used to divide program into many
small, manageable, logical and functional modules or blocks.
■ Modular programming is a software design technique that emphasizes
separating the functionality of a program into independent,
interchangeable modules, such that each contains everything necessary
to execute only one aspect of the desired functionality.
Modular Programming
Cont……..
■ Every modular program consist of one main module and one or more
sub modules or procedures.
■ Each module has a unique name.
■ Main module is the top level module in which program entry and exist
takes place.
■ The main module is the controlling section of a modular programming.
■ Sub modules is a block of statement that is used for specific task and is
written under the main module.
■ It allows the user to divide into manageable and functional modules or
blocks with the help of sub procedure and function procedure.
Modular Programming
Cont……
■ QBASIC programs consists of one or more modules.
■ A module is a block of statement that solve particular
problem.
■ A module may contain SUB and FUNCTION
procedure, as well as code not part of SUB or
FUNCTION
Modular Programming
Modular Programming
Advantages
■ Different programmers can design different program modules independently, which is
required in a large and complex program.
■ it is easy to design code and test the program modules independently.
■ It is possible to use a single module in different places which reduces program codes.
■ Reduce redundancy
■ Improving the readability of a program.
■ Program maintenance becomes easier.
■ Saving the time.
■ Encourages re-use of code.
Modular Programming
Types of Procedures
■ In QBASIC, a programmer can name a block of code which
can be executed by simply calling out that name.These name
blocks of code are called procedures.
■ The two types of procedures are:
i. SUB Procedure
ii. Function Procedure
Modular Programming
SUB Procedure
■ SUB procedure is a block of statements which is identified by
a unique name that performs a specific task.
■ The block of statements is placed with a pair of SUB … END
SUB statements and can be called by its name.
■ A SUB-procedure is a small, logical and manageable
functional part of program which performs specific task and
does not return any value.
Modular Programming
Features of SUB Procedures
■ SUB procedure does not return any value.
■ SUB procedure can be recursive.They may call
themselves.
■ Sub procedure do not have data types.
Modular Programming
SYNTAX (Parameterized)
■ Declaration
DECLARE SUB <name> (parameter list)
■ Definition
SUB <name> (parameter list)
` procedure variable definitions and
statements
END SUB
■ Calling
CALL <name>(argument list)
Modular Programming
SYNTAX(Non Parameterized)
■ DECLARE SUB <name> ()
■ CALL <name>
■ SUB <name>
` procedure variable definitions and
statements
■ END SUB
Modular Programming
Declaring SUB Procedure
■ The DECLARE statements is used to declare a SUB
procedure.
■ The syntax for the DECLARE statements is as follows:
DECLARE SUB <name>(parameter list)
Example:
DECLARE SUB AOR(L,B)
Sub procedure AOR with two parameter L and B
DECLARE SUB AOR
Sub procedure AOR with no parameters
Modular Programming
Defining a SUB procedure
■ The SUB …… END SUB statements is a procedure statements
that marks the beginning and ending of a sub program.The
syntax is:
SUB <name>(parameter list)
procedure variable definitions and statements
END SUB
Modular Programming
Calling a SUB Procedure
■ The CALL statements is used to transfer control to
another procedure, a BASIC SUB program.
■ The syntax is :
CALL <name> (argument list)
Example:
CALL AOR(L,B)
Modular Programming
Function Procedure
■ A function procedure is a small, logical and functional part of a program
which performs the specific tasks and it returns a single value to the
main program or calling module.
■ The returned value may be string or number.
■ It is either called by using PRINT statement or storing a returned value
into a variable.
Modular Programming
SYNTAX(Parameterized)
■ Declaration
DECLARE FUNCTION <name> (parameter list)
■ Definition
FUNCTION <name> (parameter list)
` procedure variable definitions and statements
<name> = Expression
END FUNCTION
■ Calling
PRINT <name>(argument list)
OR
variable = <name>(argument list)
Modular Programming
SYNTAX(Non-Parameterized)
■ Declaration
DECLARE FUNCTION <name> ()
■ Definition
FUNCTION <name>
` procedure variable definitions and statements
<name> = Expression
END FUNCTION
■ Calling
PRINT <name>
OR
variable = <name>
Modular Programming
Differences
SUB Procedure Function Procedure
The block of statements placed under SUB/END SUB
statements and can be called by its name.
The block of statements placed under
FUNCTION/END FUNCTION statements and can be
invoked from the reference of the function name.
It does not return any value to the calling module It returns a single value to calling module.
It does not have any datatype in its name. It have datatype in its name which is the return value
of a function.
Modular Programming
ARGUMENTAND PARAMETER
■ The constants or variables enclosed in the parentheses are supplied to a procedure are
known as Arguments.
■ Argument are also known as Actual Parameter.
■ The variables in a procedure which accepts data or variable passed to them from the
calling module are known as Parameters.
■ Parameter are also known as Formal Parameter.
Modular Programming
LOCAL AND GLOBALVARIABLE
■ A variable which is declared inside a module and cannot be accessed by other module
is known as local variable.
■ All variables that are declared either implicitly or explicitly without using SHARED
attribute are local variable.
■ The variable in main module which ca be accessed from any module or procedure of a
program is known as Global variable.
■ A Global variable is declared in the main module by two methods.
Modular Programming
1. Declaring by using COMMON Statement.
Syntax:
COMMON SHARED Variable list
where,
SHARED indicates that variable are shared with all procedures.
variable list A list of one or more variables to be shared in the program.
e.g. COMMON SHARED A, B, C
2. Declaring using DIM statement.
Syntax:
DIM SHARED variable list
e.g. DIM SHARED A$
Modular Programming
SHARINGAVARIABLES DEFINED IN A
MAIN MODULEWITH IN A PROCEDURE
Modular Programming
■ Variables can be shared among parts of a module without making the variables global
by using the SHARED statement.
Syntax:
SHARED variable list
e.g.
DECLARE SUBTEMPERATURE()
INPUT”ENTERTEMPERATURE IN CELCIUS”;C
CALLTEMPERATURE
END
SUBTEMPERATURE
SHARED C
F= 9 * C/5 + 32
PRINT “TEMPERATURE IN FAHRENHEIT”;F
END SUB
Modular Programming
Thank you
Modular Programming

More Related Content

What's hot

Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
lavanya marichamy
 
Python functions
Python functionsPython functions
Python functions
Prof. Dr. K. Adisesha
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
Md Soyaib
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
TMARAGATHAM
 
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
sangrampatil81
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Anil Kumar
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
Mohammed Sikander
 
Modular programming
Modular programmingModular programming
Structure in C
Structure in CStructure in C
Structure in C
Kamal Acharya
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
Boopathi K
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
Spotle.ai
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Trivuz ত্রিভুজ
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
structured programming
structured programmingstructured programming
structured programming
Ahmad54321
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
AmanuelZewdie4
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Introduction to Python programming
Introduction to Python programmingIntroduction to Python programming
Introduction to Python programming
Damian T. Gordon
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 

What's hot (20)

Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
Python functions
Python functionsPython functions
Python functions
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Modular programming
Modular programmingModular programming
Modular programming
 
Structure in C
Structure in CStructure in C
Structure in C
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
structured programming
structured programmingstructured programming
structured programming
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Introduction to Python programming
Introduction to Python programmingIntroduction to Python programming
Introduction to Python programming
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 

Similar to Modular programming

Modular programming
Modular programmingModular programming
Modular programming
bhuwanbist1
 
Presentation of computer
Presentation of computerPresentation of computer
Presentation of computer
SabinDhakal13
 
Sub-programs
Sub-programsSub-programs
Sub-programs
Forrester High School
 
Plc part 3
Plc  part 3Plc  part 3
Plc part 3
Taymoor Nazmy
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
Diwakar Pratap Singh 'Deva'
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on lineMilind Patil
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
Jeet Thombare
 
Using general sub procedures
Using general sub proceduresUsing general sub procedures
Using general sub procedures
Danica Denice Epino
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
miki304759
 
Skillwise - Cobol Programming Basics
Skillwise - Cobol Programming BasicsSkillwise - Cobol Programming Basics
Skillwise - Cobol Programming Basics
Skillwise Group
 
object oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxobject oriented programming part inheritance.pptx
object oriented programming part inheritance.pptx
urvashipundir04
 
Functions
FunctionsFunctions
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
sidhantkulkarni1
 
c#.pptx
c#.pptxc#.pptx
C PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdfC PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdf
D.K.M college for women
 
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
Vasudev Sharma
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
DivyaKS12
 
Oosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction partOosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction part
ManuSingh669370
 
10. sub program
10. sub program10. sub program

Similar to Modular programming (20)

Modular programming
Modular programmingModular programming
Modular programming
 
Presentation of computer
Presentation of computerPresentation of computer
Presentation of computer
 
Sub-programs
Sub-programsSub-programs
Sub-programs
 
Plc part 3
Plc  part 3Plc  part 3
Plc part 3
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
 
Using general sub procedures
Using general sub proceduresUsing general sub procedures
Using general sub procedures
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
Skillwise - Cobol Programming Basics
Skillwise - Cobol Programming BasicsSkillwise - Cobol Programming Basics
Skillwise - Cobol Programming Basics
 
object oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxobject oriented programming part inheritance.pptx
object oriented programming part inheritance.pptx
 
Functions
FunctionsFunctions
Functions
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
 
C PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdfC PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdf
 
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 
Coding
CodingCoding
Coding
 
Oosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction partOosd lecture unit 4 ppt introduction part
Oosd lecture unit 4 ppt introduction part
 
10. sub program
10. sub program10. sub program
10. sub program
 

More from RoshanMaharjan13

E-Commerce.pptx
E-Commerce.pptxE-Commerce.pptx
E-Commerce.pptx
RoshanMaharjan13
 
Computer security
Computer securityComputer security
Computer security
RoshanMaharjan13
 
File handling
File handlingFile handling
File handling
RoshanMaharjan13
 
Ethical and Social Issues in ICT
Ethical and Social Issues in ICTEthical and Social Issues in ICT
Ethical and Social Issues in ICT
RoshanMaharjan13
 
Basic of qbasic
Basic of qbasicBasic of qbasic
Basic of qbasic
RoshanMaharjan13
 
Ms access
Ms accessMs access
Ms access
RoshanMaharjan13
 
Ms access
Ms accessMs access
Ms access
RoshanMaharjan13
 
Computer Software
Computer SoftwareComputer Software
Computer Software
RoshanMaharjan13
 
Number system
Number systemNumber system
Number system
RoshanMaharjan13
 
Computer hardware
Computer hardwareComputer hardware
Computer hardware
RoshanMaharjan13
 
Networking and telecommunication
Networking and telecommunication Networking and telecommunication
Networking and telecommunication
RoshanMaharjan13
 
Categories of computer
Categories of computerCategories of computer
Categories of computer
RoshanMaharjan13
 
Microsoft word
Microsoft wordMicrosoft word
Microsoft word
RoshanMaharjan13
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
RoshanMaharjan13
 

More from RoshanMaharjan13 (14)

E-Commerce.pptx
E-Commerce.pptxE-Commerce.pptx
E-Commerce.pptx
 
Computer security
Computer securityComputer security
Computer security
 
File handling
File handlingFile handling
File handling
 
Ethical and Social Issues in ICT
Ethical and Social Issues in ICTEthical and Social Issues in ICT
Ethical and Social Issues in ICT
 
Basic of qbasic
Basic of qbasicBasic of qbasic
Basic of qbasic
 
Ms access
Ms accessMs access
Ms access
 
Ms access
Ms accessMs access
Ms access
 
Computer Software
Computer SoftwareComputer Software
Computer Software
 
Number system
Number systemNumber system
Number system
 
Computer hardware
Computer hardwareComputer hardware
Computer hardware
 
Networking and telecommunication
Networking and telecommunication Networking and telecommunication
Networking and telecommunication
 
Categories of computer
Categories of computerCategories of computer
Categories of computer
 
Microsoft word
Microsoft wordMicrosoft word
Microsoft word
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
 

Recently uploaded

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 

Recently uploaded (20)

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 

Modular programming

  • 1. MODULAR PROGRAMMING Prepared by: Roshan Maharjan Modular Programming
  • 2. OVERVIEW ■ Modular programming is a technique of developing software by separating the functionality of a program into independent interchangeable modules that are combined together to get the final working software. ■ Modular programming is a technique used to divide program into many small, manageable, logical and functional modules or blocks. ■ Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality. Modular Programming
  • 3. Cont…….. ■ Every modular program consist of one main module and one or more sub modules or procedures. ■ Each module has a unique name. ■ Main module is the top level module in which program entry and exist takes place. ■ The main module is the controlling section of a modular programming. ■ Sub modules is a block of statement that is used for specific task and is written under the main module. ■ It allows the user to divide into manageable and functional modules or blocks with the help of sub procedure and function procedure. Modular Programming
  • 4. Cont…… ■ QBASIC programs consists of one or more modules. ■ A module is a block of statement that solve particular problem. ■ A module may contain SUB and FUNCTION procedure, as well as code not part of SUB or FUNCTION Modular Programming
  • 6. Advantages ■ Different programmers can design different program modules independently, which is required in a large and complex program. ■ it is easy to design code and test the program modules independently. ■ It is possible to use a single module in different places which reduces program codes. ■ Reduce redundancy ■ Improving the readability of a program. ■ Program maintenance becomes easier. ■ Saving the time. ■ Encourages re-use of code. Modular Programming
  • 7. Types of Procedures ■ In QBASIC, a programmer can name a block of code which can be executed by simply calling out that name.These name blocks of code are called procedures. ■ The two types of procedures are: i. SUB Procedure ii. Function Procedure Modular Programming
  • 8. SUB Procedure ■ SUB procedure is a block of statements which is identified by a unique name that performs a specific task. ■ The block of statements is placed with a pair of SUB … END SUB statements and can be called by its name. ■ A SUB-procedure is a small, logical and manageable functional part of program which performs specific task and does not return any value. Modular Programming
  • 9. Features of SUB Procedures ■ SUB procedure does not return any value. ■ SUB procedure can be recursive.They may call themselves. ■ Sub procedure do not have data types. Modular Programming
  • 10. SYNTAX (Parameterized) ■ Declaration DECLARE SUB <name> (parameter list) ■ Definition SUB <name> (parameter list) ` procedure variable definitions and statements END SUB ■ Calling CALL <name>(argument list) Modular Programming
  • 11. SYNTAX(Non Parameterized) ■ DECLARE SUB <name> () ■ CALL <name> ■ SUB <name> ` procedure variable definitions and statements ■ END SUB Modular Programming
  • 12. Declaring SUB Procedure ■ The DECLARE statements is used to declare a SUB procedure. ■ The syntax for the DECLARE statements is as follows: DECLARE SUB <name>(parameter list) Example: DECLARE SUB AOR(L,B) Sub procedure AOR with two parameter L and B DECLARE SUB AOR Sub procedure AOR with no parameters Modular Programming
  • 13. Defining a SUB procedure ■ The SUB …… END SUB statements is a procedure statements that marks the beginning and ending of a sub program.The syntax is: SUB <name>(parameter list) procedure variable definitions and statements END SUB Modular Programming
  • 14. Calling a SUB Procedure ■ The CALL statements is used to transfer control to another procedure, a BASIC SUB program. ■ The syntax is : CALL <name> (argument list) Example: CALL AOR(L,B) Modular Programming
  • 15. Function Procedure ■ A function procedure is a small, logical and functional part of a program which performs the specific tasks and it returns a single value to the main program or calling module. ■ The returned value may be string or number. ■ It is either called by using PRINT statement or storing a returned value into a variable. Modular Programming
  • 16. SYNTAX(Parameterized) ■ Declaration DECLARE FUNCTION <name> (parameter list) ■ Definition FUNCTION <name> (parameter list) ` procedure variable definitions and statements <name> = Expression END FUNCTION ■ Calling PRINT <name>(argument list) OR variable = <name>(argument list) Modular Programming
  • 17. SYNTAX(Non-Parameterized) ■ Declaration DECLARE FUNCTION <name> () ■ Definition FUNCTION <name> ` procedure variable definitions and statements <name> = Expression END FUNCTION ■ Calling PRINT <name> OR variable = <name> Modular Programming
  • 18. Differences SUB Procedure Function Procedure The block of statements placed under SUB/END SUB statements and can be called by its name. The block of statements placed under FUNCTION/END FUNCTION statements and can be invoked from the reference of the function name. It does not return any value to the calling module It returns a single value to calling module. It does not have any datatype in its name. It have datatype in its name which is the return value of a function. Modular Programming
  • 19. ARGUMENTAND PARAMETER ■ The constants or variables enclosed in the parentheses are supplied to a procedure are known as Arguments. ■ Argument are also known as Actual Parameter. ■ The variables in a procedure which accepts data or variable passed to them from the calling module are known as Parameters. ■ Parameter are also known as Formal Parameter. Modular Programming
  • 20. LOCAL AND GLOBALVARIABLE ■ A variable which is declared inside a module and cannot be accessed by other module is known as local variable. ■ All variables that are declared either implicitly or explicitly without using SHARED attribute are local variable. ■ The variable in main module which ca be accessed from any module or procedure of a program is known as Global variable. ■ A Global variable is declared in the main module by two methods. Modular Programming
  • 21. 1. Declaring by using COMMON Statement. Syntax: COMMON SHARED Variable list where, SHARED indicates that variable are shared with all procedures. variable list A list of one or more variables to be shared in the program. e.g. COMMON SHARED A, B, C 2. Declaring using DIM statement. Syntax: DIM SHARED variable list e.g. DIM SHARED A$ Modular Programming
  • 22. SHARINGAVARIABLES DEFINED IN A MAIN MODULEWITH IN A PROCEDURE Modular Programming
  • 23. ■ Variables can be shared among parts of a module without making the variables global by using the SHARED statement. Syntax: SHARED variable list e.g. DECLARE SUBTEMPERATURE() INPUT”ENTERTEMPERATURE IN CELCIUS”;C CALLTEMPERATURE END SUBTEMPERATURE SHARED C F= 9 * C/5 + 32 PRINT “TEMPERATURE IN FAHRENHEIT”;F END SUB Modular Programming