SlideShare a Scribd company logo
1 of 21
Modular Programming
Chapter-9
Class-10
Presented By: Bibash Pokhrel
Computer Science Teacher,
Shubhakamana Academy
Overview
• Modular programming is a technique of
developing software by separating the
functionality of a program into independent,
interchangeable modules that are combine
together to get the final working software.
Cont….
• Every modular program has one main module
and may have many sub modules.
• Main module is the top level module in which
program entry and exist takes place.
• Sub module is a block of statement that is
used for specific task and is controlled by main
module.
Structure of Modular Programming
Main
Program-M1
Module-M2
Module-M5 Module-M6
Module-M3 Module-M4
Module-M7
Cont…
• Qbasic programs consist 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.
Advantages of modular programming
• The modular design offers several advantages
such as:
a. Improving the readability of a program.
b. Reducing redundancy.
c. Saving the time during project development.
d. Modules can be tested independently.
e. Program maintenance becomes easier.
Types of Procedures in Qbasic program
• 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
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.
Features of SUB Procedure
• SUB procedure cannot be a part of an
expression and does not return any value.
• SUB procedure can be recursive. They may call
themselves.
• SUB procedure do not have data type.
• The parameters can be passed by reference or
by value.
Declaring SUB Procedure
• The DECLARE statement is used to declare a
SUB procedure.
• The syntax for the DECLARE statement is as
follows:
– DECLARE SUB name (parameter list)
– Example:
DECLARE SUB area(L,B)
Sub procedure area with two parameters L and B
DECLARE SUB Display()
Sub procedure Display with no parameters
Defining a SUB Procedure
• The SUB….END SUB statement is a procedure
statement that marks the beginning and
ending of a subprogram. The syntax is:
SUB Procedure_name[parameter,(list..)]
…’procedure variable definitions and
statements
END SUB
Calling a SUB Procedure
• The CALL statement is used to transfer control
to another procedure, a BASIC SUB program.
The syntax is :
CALL name (argument lit)
Example:
CALL area(r)
Example
• Write a program to create a procedure using
SUB…END SUB to input the value of length,
breadth and height of a box. The program
should calculate the area and volume of a box.
• Answer:
• DECLARE SUB area (l!,b!,h!)
• DECLARE SUB vol (l!,b!,h!)
• INPUT”Enter a length of a box”; l
Cont….
INPUT”Enter a breadth of a box”;b
INPUT”Enter a height of a box”;h
CALL area(l,b)
CALL vol(l,b,h)
END
SUB area(l,b)
a=2*(l+b*h+l*h)
PRINT “Area of box”;a
END SUB
Cont….
SUB vol(l,b,h)
v=l*b*h
PRINT “Volume of a box”;v
END SUB
FUNCTION Procedure
• A function block statement is used to create a
function procedure to return a calculated
value to a program.
Features of FUNCTION Procedure
a. FUNCTION procedure are used in expressions
and can directly return a single value.
b. FUNCTION procedure can be recursive. A
recursive function is one that calls itself.
c. FUNCTION procedure have a data type which
is the return value of the function.
d. The parameters can be passed by reference
or by value.
Example
Q. Write a program to declare a user defined
function using FUNCTION…..END FUNCTION to
print the area of a triangle by using expression
method.
Ans. DECLARE FUNCTION area(b!,h!)
INPUT”Enter a base of a triangle:”;b
INPUT”Enter a height of a triangle:”;h
triangle=area(b,h)
PRINT “Area of a triangle=”;triangle
END
Cont…
FUNCTION area(b,h)
a=1/2*b*h
area= a
END FUNCTION
The difference between Function
procedure and Sub procedure
Sub Procedure Function Procedure
The block of statements is placed with a
pair of SUB/END SUB statements and can
be called by its name
The block of statements is placed with a
pair of FUNCTION/END FUNCTION
statements and can be invoked from the
reference of the function name.
It does not return any value. It directly returns a single value.
It does not have a data type. It has a data type which is the return
value of the function.
What are parameters?
Parameters are variables that receives data
(argument values) and to the procedures
(SUB/FUNCTIO N procedures).

More Related Content

What's hot (20)

Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners
 
Language translator
Language translatorLanguage translator
Language translator
 
Inheritance
InheritanceInheritance
Inheritance
 
SPL 1 | Introduction to Structured programming language
SPL 1 | Introduction to Structured programming languageSPL 1 | Introduction to Structured programming language
SPL 1 | Introduction to Structured programming language
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
White box ppt
White box pptWhite box ppt
White box ppt
 
Oops in vb
Oops in vbOops in vb
Oops in vb
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
Java servlets and CGI
Java servlets and CGIJava servlets and CGI
Java servlets and CGI
 
class and objects
class and objectsclass and objects
class and objects
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
structured programming
structured programmingstructured programming
structured programming
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 

Similar to Modular programming

Presentation of computer
Presentation of computerPresentation of computer
Presentation of computerSabinDhakal13
 
Modular programming
Modular programmingModular programming
Modular programmingbhuwanbist1
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptxmiki304759
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in Cbhawna kol
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptManivannan837728
 
Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)ViswanathanS21
 
5. Functions in C.pdf
5. Functions in C.pdf5. Functions in C.pdf
5. Functions in C.pdfsantosh147365
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C ProgrammingShuvongkor Barman
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptxAshwini Raut
 
c.p function
c.p functionc.p function
c.p functiongiri5624
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptAmanuelZewdie4
 

Similar to Modular programming (20)

Presentation of computer
Presentation of computerPresentation of computer
Presentation of computer
 
Modular programming
Modular programmingModular programming
Modular programming
 
Modular programming
Modular programmingModular programming
Modular programming
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
Plc part 3
Plc  part 3Plc  part 3
Plc part 3
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in C
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
 
Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)
 
Using general sub procedures
Using general sub proceduresUsing general sub procedures
Using general sub procedures
 
Sub-programs
Sub-programsSub-programs
Sub-programs
 
5. Functions in C.pdf
5. Functions in C.pdf5. Functions in C.pdf
5. Functions in C.pdf
 
Functions in c
Functions in cFunctions in c
Functions in c
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
C language updated
C language updatedC language updated
C language updated
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptx
 
c.p function
c.p functionc.p function
c.p function
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
 

Recently uploaded

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 

Recently uploaded (20)

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 

Modular programming

  • 1. Modular Programming Chapter-9 Class-10 Presented By: Bibash Pokhrel Computer Science Teacher, Shubhakamana Academy
  • 2. Overview • Modular programming is a technique of developing software by separating the functionality of a program into independent, interchangeable modules that are combine together to get the final working software.
  • 3. Cont…. • Every modular program has one main module and may have many sub modules. • Main module is the top level module in which program entry and exist takes place. • Sub module is a block of statement that is used for specific task and is controlled by main module.
  • 4. Structure of Modular Programming Main Program-M1 Module-M2 Module-M5 Module-M6 Module-M3 Module-M4 Module-M7
  • 5. Cont… • Qbasic programs consist 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.
  • 6. Advantages of modular programming • The modular design offers several advantages such as: a. Improving the readability of a program. b. Reducing redundancy. c. Saving the time during project development. d. Modules can be tested independently. e. Program maintenance becomes easier.
  • 7. Types of Procedures in Qbasic program • 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
  • 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.
  • 9. Features of SUB Procedure • SUB procedure cannot be a part of an expression and does not return any value. • SUB procedure can be recursive. They may call themselves. • SUB procedure do not have data type. • The parameters can be passed by reference or by value.
  • 10. Declaring SUB Procedure • The DECLARE statement is used to declare a SUB procedure. • The syntax for the DECLARE statement is as follows: – DECLARE SUB name (parameter list) – Example: DECLARE SUB area(L,B) Sub procedure area with two parameters L and B DECLARE SUB Display() Sub procedure Display with no parameters
  • 11. Defining a SUB Procedure • The SUB….END SUB statement is a procedure statement that marks the beginning and ending of a subprogram. The syntax is: SUB Procedure_name[parameter,(list..)] …’procedure variable definitions and statements END SUB
  • 12. Calling a SUB Procedure • The CALL statement is used to transfer control to another procedure, a BASIC SUB program. The syntax is : CALL name (argument lit) Example: CALL area(r)
  • 13. Example • Write a program to create a procedure using SUB…END SUB to input the value of length, breadth and height of a box. The program should calculate the area and volume of a box. • Answer: • DECLARE SUB area (l!,b!,h!) • DECLARE SUB vol (l!,b!,h!) • INPUT”Enter a length of a box”; l
  • 14. Cont…. INPUT”Enter a breadth of a box”;b INPUT”Enter a height of a box”;h CALL area(l,b) CALL vol(l,b,h) END SUB area(l,b) a=2*(l+b*h+l*h) PRINT “Area of box”;a END SUB
  • 16. FUNCTION Procedure • A function block statement is used to create a function procedure to return a calculated value to a program.
  • 17. Features of FUNCTION Procedure a. FUNCTION procedure are used in expressions and can directly return a single value. b. FUNCTION procedure can be recursive. A recursive function is one that calls itself. c. FUNCTION procedure have a data type which is the return value of the function. d. The parameters can be passed by reference or by value.
  • 18. Example Q. Write a program to declare a user defined function using FUNCTION…..END FUNCTION to print the area of a triangle by using expression method. Ans. DECLARE FUNCTION area(b!,h!) INPUT”Enter a base of a triangle:”;b INPUT”Enter a height of a triangle:”;h triangle=area(b,h) PRINT “Area of a triangle=”;triangle END
  • 20. The difference between Function procedure and Sub procedure Sub Procedure Function Procedure The block of statements is placed with a pair of SUB/END SUB statements and can be called by its name The block of statements is placed with a pair of FUNCTION/END FUNCTION statements and can be invoked from the reference of the function name. It does not return any value. It directly returns a single value. It does not have a data type. It has a data type which is the return value of the function.
  • 21. What are parameters? Parameters are variables that receives data (argument values) and to the procedures (SUB/FUNCTIO N procedures).