SlideShare a Scribd company logo
3
Most read
17
Most read
20
Most read
LOGO
11
MODULAR PROGRAMMINGMODULAR PROGRAMMING
Submitted to: Submitted by:Submitted to: Submitted by:
Mrs. Priyanka Soni Krati KatyalMrs. Priyanka Soni Krati Katyal
MCA 1MCA 1stst
SemSem
Topics Covered
• Modular Programing
• Need of Modular Programming
• Why Modular Programming??
• Modularity
• Elements of Modular Programming
• Modular Programming Example
• Advantages of Modular Programming
• Disadvantages of Modular Programming
• Reference
Modular ProgrammingModular Programming
Modular programmingModular programming is a software designis a software design
technique that emphasizes separating thetechnique that emphasizes separating the
functionality of afunctionality of a programprogram into independent,into independent,
interchangeable modules, such that each containsinterchangeable modules, such that each contains
everything necessary to execute only one aspect ofeverything necessary to execute only one aspect of
the desired functionality.the desired functionality.
Need for Modular ProgrammingNeed for Modular Programming
• When a program becomes very large andWhen a program becomes very large and
complex, it becomes very difficult task for thecomplex, it becomes very difficult task for the
programmers to design, test and debug such aprogrammers to design, test and debug such a
program.program.
• Therefore a long program can be divided into aTherefore a long program can be divided into a
smaller program called modules as the modulessmaller program called modules as the modules
can be designed, tested and debugged separately,can be designed, tested and debugged separately,
the task of programmer becomes easy andthe task of programmer becomes easy and
convenient.convenient.
• It makes your program easy to understand.It makes your program easy to understand.
• Helps manage complexityHelps manage complexity
o Smaller blocks of codeSmaller blocks of code
o Easier to readEasier to read
• Encourages re-use of codeEncourages re-use of code
Within a particular program or acrossWithin a particular program or across
different programsdifferent programs
• Allows independent development of codeAllows independent development of code
Why Modular Programming??Why Modular Programming??
ModularityModularity
• How do you solve a big/complexHow do you solve a big/complex
problem?problem?
• Divide it into small tasks and solve eachDivide it into small tasks and solve each
task. Then combine these solutions.task. Then combine these solutions.
Divide and ConquerDivide and Conquer
• In C we useIn C we use functionsfunctions also referred to asalso referred to as
modulesmodules to perform specific tasks that weto perform specific tasks that we
determined in our solutiondetermined in our solution
• This strategy is essentially based on theThis strategy is essentially based on the
divide-and-conquer approach to problemdivide-and-conquer approach to problem
solving and has many advantages oversolving and has many advantages over
developing a program for the entire problem.developing a program for the entire problem.
• We will assign a name to each module andWe will assign a name to each module and
combine the named modules in a programcombine the named modules in a program
structure under the control of a mainstructure under the control of a main
program.program.
• Such a program structure consists of aSuch a program structure consists of a
set of modules and an order ofset of modules and an order of
execution.execution.
Elements of Modular ProgrammingElements of Modular Programming
• C requires that function names be unique in aC requires that function names be unique in a
source program file.source program file.
• Program execution always begins and eventuallyProgram execution always begins and eventually
terminates in the main function.terminates in the main function.
• Additional functions are called or invoked whenAdditional functions are called or invoked when
the program encounters function namesthe program encounters function names
• Functions could beFunctions could be
Pre-defined library functions (e.g., printf, sin, tan)Pre-defined library functions (e.g., printf, sin, tan)
oror
Programmer-defined functions (e.g., my_printf,Programmer-defined functions (e.g., my_printf,
area)area)
• FunctionsFunctions Perform a specific taskPerform a specific task
 Arguments with no return typeArguments with no return type
void fun(int x, int y)void fun(int x, int y)
{{
//statement//statement
}}
 Arguments with return typeArguments with return type
int fun(int x, int y)int fun(int x, int y)
{{
//statement//statement
return 0;return 0;
}}
 No arguments with no return typeNo arguments with no return type
void fun( )void fun( )
{{
//statement//statement
}}
 No Arguments with return typeNo Arguments with return type
int fun( )int fun( )
{{
//statement//statement
return 0;return 0;
}}
These functions require three elements:These functions require three elements:
1.1.Function declaration: In this only theFunction declaration: In this only the
name and the syntax of the function willname and the syntax of the function will
written.written.
2.2. Function calls: In this program will callFunction calls: In this program will call
the functionthe function
3. Function definition: In this program3. Function definition: In this program
will defines that how the function willwill defines that how the function will
perform there task.perform there task.
A function definition consists ofA function definition consists of
1. A function type1. A function type
2. A function name2. A function name
3. An optional list of formal parameters enclosed in3. An optional list of formal parameters enclosed in
parenthesesparentheses
4. A compound statement.4. A compound statement.
Ex : Void start(int a)Ex : Void start(int a)
{{
…….statement…...statement…..
}}
#include <stdio.h>#include <stdio.h>
int max(int num1, int num2);int max(int num1, int num2);
int main ()int main ()
{{
int a = 100;int a = 100;
int b = 200;int b = 200;
int ret;int ret;
ret = max(a, b);ret = max(a, b);
printf( "Max value is : %dn", ret );printf( "Max value is : %dn", ret );
Modular Programming ExampleModular Programming Example
return 0;return 0;
}}
int max(int num1, int num2)int max(int num1, int num2)
{{
int result;int result;
if (num1 > num2)if (num1 > num2)
result = num1;result = num1;
elseelse
result = num2;result = num2;
return result;return result;
}}
OutputOutput
Max value is : 200Max value is : 200
Advantages of using modulesAdvantages of using modules
• Modules can be written and testedModules can be written and tested
separatelyseparately
• Modules can be reusedModules can be reused
• Large projects can be developed inLarge projects can be developed in
parallelparallel
• Reduces length of program, making itReduces length of program, making it
more readablemore readable
• Promotes the concept ofPromotes the concept of abstractionabstraction
 A module hides details of a taskA module hides details of a task
 We just need to know what this moduleWe just need to know what this module
doesdoes
 We don’t need to know how it does itWe don’t need to know how it does it
Disadvantages of using modulesDisadvantages of using modules
• means documentation of modules must bemeans documentation of modules must be
systematicsystematic
• can lead to problems when modules are linkedcan lead to problems when modules are linked
because link must thoroughly testedbecause link must thoroughly tested
• Since separate modules map repeat certainSince separate modules map repeat certain
functions, the modular programming oftenfunctions, the modular programming often
need extra time and memory.need extra time and memory.
ReferenceReference
www.google.comwww.google.com
www.encyclopedia.comwww.encyclopedia.com
www.wikipedia.comwww.wikipedia.com
www.ctutorial.comwww.ctutorial.com
Thank You
MLSU
UNIVERSITY

More Related Content

What's hot (20)

PDF
Class and Objects in Java
Spotle.ai
 
PPTX
Data types
Nokesh Prabhakar
 
ODP
Python Modules
Nitin Reddy Katkam
 
PPT
Final keyword in java
Lovely Professional University
 
PPTX
Functions in C
Kamal Acharya
 
PPTX
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
PPTX
User defined functions in C
Harendra Singh
 
PPTX
Type casting in java
Farooq Baloch
 
PPTX
Algorithm
IHTISHAM UL HAQ
 
PDF
Introduction to oops concepts
Nilesh Dalvi
 
PPTX
C functions
University of Potsdam
 
PPTX
Operators in java
Then Murugeshwari
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPTX
Functions in python
colorsof
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPTX
Object Oriented Programming Using C++
Muhammad Waqas
 
PDF
Applications of stack
eShikshak
 
PPTX
Function in C program
Nurul Zakiah Zamri Tan
 
PDF
Methods in Java
Jussi Pohjolainen
 
PPTX
Dynamic memory allocation in c
lavanya marichamy
 
Class and Objects in Java
Spotle.ai
 
Data types
Nokesh Prabhakar
 
Python Modules
Nitin Reddy Katkam
 
Final keyword in java
Lovely Professional University
 
Functions in C
Kamal Acharya
 
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
User defined functions in C
Harendra Singh
 
Type casting in java
Farooq Baloch
 
Algorithm
IHTISHAM UL HAQ
 
Introduction to oops concepts
Nilesh Dalvi
 
Operators in java
Then Murugeshwari
 
Classes, objects in JAVA
Abhilash Nair
 
Functions in python
colorsof
 
classes and objects in C++
HalaiHansaika
 
Object Oriented Programming Using C++
Muhammad Waqas
 
Applications of stack
eShikshak
 
Function in C program
Nurul Zakiah Zamri Tan
 
Methods in Java
Jussi Pohjolainen
 
Dynamic memory allocation in c
lavanya marichamy
 

Viewers also liked (6)

PPT
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Mohanlal Sukhadia University (MLSU)
 
PPTX
And or graph problem reduction using predicate logic
Mohanlal Sukhadia University (MLSU)
 
PPT
Knapsack problem using fixed tuple
Mohanlal Sukhadia University (MLSU)
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Mohanlal Sukhadia University (MLSU)
 
And or graph problem reduction using predicate logic
Mohanlal Sukhadia University (MLSU)
 
Knapsack problem using fixed tuple
Mohanlal Sukhadia University (MLSU)
 
Ad

Similar to Modular programming (20)

PPTX
Chapter One Function.pptx
miki304759
 
PDF
Booting into functional programming
Dhaval Dalal
 
PPTX
Functions
Lakshmi Sarvani Videla
 
PPTX
Mastering Python lesson 4_functions_parameters_arguments
Ruth Marvin
 
PPT
U19CS101 - PPS Unit 4 PPT (1).ppt
Manivannan837728
 
PDF
5. Functions in C.pdf
santosh147365
 
PDF
C Interview Questions PDF By Scholarhat.pdf
Scholarhat
 
PPT
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
harinipradeep15
 
PPTX
Funtions of c programming. the functions of c helps to clarify all the tops
sameermhr345
 
PPTX
pythontraining-201jn026043638.pptx
RohitKumar639388
 
PDF
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Ovidiu Farauanu
 
PPTX
Python training
Kunalchauhan76
 
PPT
Oop(object oriented programming)
geetika goyal
 
PPTX
object oriented programming part inheritance.pptx
urvashipundir04
 
PDF
Functions
Learn By Watch
 
PDF
ceng2404314334535365_hgf66353week_07-08_v0.8.pdf
eagac2004
 
PPTX
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
PDF
VIT351 Software Development VI Unit1
YOGESH SINGH
 
PPTX
Function oneshot with python programming .pptx
lionsconvent1234
 
PPTX
Different paradigms for problem solving.pptx
iitjeesooraj
 
Chapter One Function.pptx
miki304759
 
Booting into functional programming
Dhaval Dalal
 
Mastering Python lesson 4_functions_parameters_arguments
Ruth Marvin
 
U19CS101 - PPS Unit 4 PPT (1).ppt
Manivannan837728
 
5. Functions in C.pdf
santosh147365
 
C Interview Questions PDF By Scholarhat.pdf
Scholarhat
 
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
harinipradeep15
 
Funtions of c programming. the functions of c helps to clarify all the tops
sameermhr345
 
pythontraining-201jn026043638.pptx
RohitKumar639388
 
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Ovidiu Farauanu
 
Python training
Kunalchauhan76
 
Oop(object oriented programming)
geetika goyal
 
object oriented programming part inheritance.pptx
urvashipundir04
 
Functions
Learn By Watch
 
ceng2404314334535365_hgf66353week_07-08_v0.8.pdf
eagac2004
 
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
VIT351 Software Development VI Unit1
YOGESH SINGH
 
Function oneshot with python programming .pptx
lionsconvent1234
 
Different paradigms for problem solving.pptx
iitjeesooraj
 
Ad

Recently uploaded (20)

PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Design Thinking basics for Engineers.pdf
CMR University
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 

Modular programming

  • 1. LOGO 11 MODULAR PROGRAMMINGMODULAR PROGRAMMING Submitted to: Submitted by:Submitted to: Submitted by: Mrs. Priyanka Soni Krati KatyalMrs. Priyanka Soni Krati Katyal MCA 1MCA 1stst SemSem
  • 2. Topics Covered • Modular Programing • Need of Modular Programming • Why Modular Programming?? • Modularity • Elements of Modular Programming • Modular Programming Example • Advantages of Modular Programming • Disadvantages of Modular Programming • Reference
  • 3. Modular ProgrammingModular Programming Modular programmingModular programming is a software designis a software design technique that emphasizes separating thetechnique that emphasizes separating the functionality of afunctionality of a programprogram into independent,into independent, interchangeable modules, such that each containsinterchangeable modules, such that each contains everything necessary to execute only one aspect ofeverything necessary to execute only one aspect of the desired functionality.the desired functionality.
  • 4. Need for Modular ProgrammingNeed for Modular Programming • When a program becomes very large andWhen a program becomes very large and complex, it becomes very difficult task for thecomplex, it becomes very difficult task for the programmers to design, test and debug such aprogrammers to design, test and debug such a program.program. • Therefore a long program can be divided into aTherefore a long program can be divided into a smaller program called modules as the modulessmaller program called modules as the modules can be designed, tested and debugged separately,can be designed, tested and debugged separately, the task of programmer becomes easy andthe task of programmer becomes easy and convenient.convenient. • It makes your program easy to understand.It makes your program easy to understand.
  • 5. • Helps manage complexityHelps manage complexity o Smaller blocks of codeSmaller blocks of code o Easier to readEasier to read • Encourages re-use of codeEncourages re-use of code Within a particular program or acrossWithin a particular program or across different programsdifferent programs • Allows independent development of codeAllows independent development of code Why Modular Programming??Why Modular Programming??
  • 6. ModularityModularity • How do you solve a big/complexHow do you solve a big/complex problem?problem? • Divide it into small tasks and solve eachDivide it into small tasks and solve each task. Then combine these solutions.task. Then combine these solutions. Divide and ConquerDivide and Conquer
  • 7. • In C we useIn C we use functionsfunctions also referred to asalso referred to as modulesmodules to perform specific tasks that weto perform specific tasks that we determined in our solutiondetermined in our solution • This strategy is essentially based on theThis strategy is essentially based on the divide-and-conquer approach to problemdivide-and-conquer approach to problem solving and has many advantages oversolving and has many advantages over developing a program for the entire problem.developing a program for the entire problem. • We will assign a name to each module andWe will assign a name to each module and combine the named modules in a programcombine the named modules in a program structure under the control of a mainstructure under the control of a main program.program.
  • 8. • Such a program structure consists of aSuch a program structure consists of a set of modules and an order ofset of modules and an order of execution.execution.
  • 9. Elements of Modular ProgrammingElements of Modular Programming • C requires that function names be unique in aC requires that function names be unique in a source program file.source program file. • Program execution always begins and eventuallyProgram execution always begins and eventually terminates in the main function.terminates in the main function. • Additional functions are called or invoked whenAdditional functions are called or invoked when the program encounters function namesthe program encounters function names • Functions could beFunctions could be Pre-defined library functions (e.g., printf, sin, tan)Pre-defined library functions (e.g., printf, sin, tan) oror Programmer-defined functions (e.g., my_printf,Programmer-defined functions (e.g., my_printf, area)area)
  • 10. • FunctionsFunctions Perform a specific taskPerform a specific task  Arguments with no return typeArguments with no return type void fun(int x, int y)void fun(int x, int y) {{ //statement//statement }}  Arguments with return typeArguments with return type int fun(int x, int y)int fun(int x, int y) {{ //statement//statement return 0;return 0; }}
  • 11.  No arguments with no return typeNo arguments with no return type void fun( )void fun( ) {{ //statement//statement }}  No Arguments with return typeNo Arguments with return type int fun( )int fun( ) {{ //statement//statement return 0;return 0; }}
  • 12. These functions require three elements:These functions require three elements: 1.1.Function declaration: In this only theFunction declaration: In this only the name and the syntax of the function willname and the syntax of the function will written.written. 2.2. Function calls: In this program will callFunction calls: In this program will call the functionthe function 3. Function definition: In this program3. Function definition: In this program will defines that how the function willwill defines that how the function will perform there task.perform there task.
  • 13. A function definition consists ofA function definition consists of 1. A function type1. A function type 2. A function name2. A function name 3. An optional list of formal parameters enclosed in3. An optional list of formal parameters enclosed in parenthesesparentheses 4. A compound statement.4. A compound statement. Ex : Void start(int a)Ex : Void start(int a) {{ …….statement…...statement….. }}
  • 14. #include <stdio.h>#include <stdio.h> int max(int num1, int num2);int max(int num1, int num2); int main ()int main () {{ int a = 100;int a = 100; int b = 200;int b = 200; int ret;int ret; ret = max(a, b);ret = max(a, b); printf( "Max value is : %dn", ret );printf( "Max value is : %dn", ret ); Modular Programming ExampleModular Programming Example
  • 15. return 0;return 0; }} int max(int num1, int num2)int max(int num1, int num2) {{ int result;int result; if (num1 > num2)if (num1 > num2) result = num1;result = num1; elseelse result = num2;result = num2; return result;return result; }}
  • 16. OutputOutput Max value is : 200Max value is : 200
  • 17. Advantages of using modulesAdvantages of using modules • Modules can be written and testedModules can be written and tested separatelyseparately • Modules can be reusedModules can be reused • Large projects can be developed inLarge projects can be developed in parallelparallel • Reduces length of program, making itReduces length of program, making it more readablemore readable • Promotes the concept ofPromotes the concept of abstractionabstraction  A module hides details of a taskA module hides details of a task  We just need to know what this moduleWe just need to know what this module doesdoes  We don’t need to know how it does itWe don’t need to know how it does it
  • 18. Disadvantages of using modulesDisadvantages of using modules • means documentation of modules must bemeans documentation of modules must be systematicsystematic • can lead to problems when modules are linkedcan lead to problems when modules are linked because link must thoroughly testedbecause link must thoroughly tested • Since separate modules map repeat certainSince separate modules map repeat certain functions, the modular programming oftenfunctions, the modular programming often need extra time and memory.need extra time and memory.