SlideShare a Scribd company logo
SUB PROGRAMS
Higher Computing Science
MODULAR CODE
• Computer programs are much easier to write and understand if they are
broken down into smaller blocks. These blocks are called sub-programs
or subroutines.
• Large programs will have teams of developers working on them. Using
sub-programs makes it easier to develop and maintain code.
SUB-PROGRAMS
• Independent block of code within the main program.
• Carries out a specific task e.g.
• calculate_area
• display_total
• move_player
• update_score
• Can be programmed and tested independently of other sub-programs.
SUB-PROGRAMS
• Each sub-program begins with a declaration which includes:
• the sub-program name
• a list of formal parameters being passed into the sub-program
FUNCTIONS
• A function is a sub-program which returns a value
PROCEDURES
• A procedure is a sub-program which produces an effect
PARAMETER PASSING
• Parameters are items of data that can be passed from the main program
to sub-programs.
Main
Program
Sub-program
Parameter
PARAMETER PASSING: PSEUDOCODE
FUNCTION calc_rectangle_area(length, breadth)
area = length * breadth
RETURN area
END FUNCTION
area_rect_1 = calc_rectangle_area(10, 4)
display area_rect_1
area_rect_2 = calc_rectangle_area(3, 6)
display area_rect_2
PARAMETER PASSING: PYTHON
FORMAL PARAMETERS
• Formal parameters are identified in the sub-program definition.
Formal
parameters
FORMAL PARAMETERS
• Actual parameters are data items that are passed to the sub-program.
Actual
parameters

More Related Content

What's hot

C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
أحمد محمد
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
Swapnali Pawar
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
VedaGayathri1
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)
SHAMJITH KM
 
Python Modules
Python ModulesPython Modules
Python Modules
Nitin Reddy Katkam
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
Samiksha Pun
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
Rohit Verma
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
Rayhan Chowdhury
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Yi-Fan Chu
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
Dr-Dipali Meher
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
SIVASHANKARIRAJAN
 
Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function
Prof.Nilesh Magar
 
Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
Poo 4 arraylist
Poo 4 arraylistPoo 4 arraylist
Poo 4 arraylist
jlmanmons
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
Namespaces
NamespacesNamespaces
Namespaces
Sangeetha S
 
Java file
Java fileJava file
Java file
sonnetdp
 

What's hot (20)

C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)
 
Python Modules
Python ModulesPython Modules
Python Modules
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Mysql creating stored function
Mysql  creating stored function Mysql  creating stored function
Mysql creating stored function
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Poo 4 arraylist
Poo 4 arraylistPoo 4 arraylist
Poo 4 arraylist
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
Namespaces
NamespacesNamespaces
Namespaces
 
Java file
Java fileJava file
Java file
 

Similar to Sub-programs

Modular programming
Modular programmingModular programming
Modular programming
RoshanMaharjan13
 
Using general sub procedures
Using general sub proceduresUsing general sub procedures
Using general sub procedures
Danica Denice Epino
 
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'
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
Jeet Thombare
 
Cte 113 slides
Cte 113 slidesCte 113 slides
Cte 113 slides
Idris Abdulhameed
 
Chapter 1 - Prog101.ppt
Chapter 1 - Prog101.pptChapter 1 - Prog101.ppt
Chapter 1 - Prog101.ppt
JosephObadiahTuray
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
Sangheethaa Sukumaran
 
C- language Lecture 4
C- language Lecture 4C- language Lecture 4
C- language Lecture 4
Hatem Abd El-Salam
 
Lecture 2.pptx
Lecture 2.pptxLecture 2.pptx
Lecture 2.pptx
EddyMakoyo1
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan
 
Vedic Calculator
Vedic CalculatorVedic Calculator
Vedic Calculator
divyang_panchasara
 
SQL Server DevOps Jumpstart
SQL Server DevOps JumpstartSQL Server DevOps Jumpstart
SQL Server DevOps Jumpstart
Ori Donner
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Tushar B Kute
 
c programming 1-1.pptx
c programming 1-1.pptxc programming 1-1.pptx
c programming 1-1.pptx
CHERUKURIYUVARAJU209
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
JAGADEESWARIS6
 
C programming
C programmingC programming
C programming
Jigarthacker
 
SE-software design.ppt
SE-software design.pptSE-software design.ppt
SE-software design.ppt
vishal choudhary
 
software process model
software process modelsoftware process model
software process model
juhi kumari
 

Similar to Sub-programs (20)

Modular programming
Modular programmingModular programming
Modular programming
 
Using general sub procedures
Using general sub proceduresUsing general sub procedures
Using general sub procedures
 
Coding
CodingCoding
Coding
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
 
Cte 113 slides
Cte 113 slidesCte 113 slides
Cte 113 slides
 
Chapter 1 - Prog101.ppt
Chapter 1 - Prog101.pptChapter 1 - Prog101.ppt
Chapter 1 - Prog101.ppt
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
C- language Lecture 4
C- language Lecture 4C- language Lecture 4
C- language Lecture 4
 
Lecture 2.pptx
Lecture 2.pptxLecture 2.pptx
Lecture 2.pptx
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
 
Vedic Calculator
Vedic CalculatorVedic Calculator
Vedic Calculator
 
5 software design
5 software design5 software design
5 software design
 
SQL Server DevOps Jumpstart
SQL Server DevOps JumpstartSQL Server DevOps Jumpstart
SQL Server DevOps Jumpstart
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
 
c programming 1-1.pptx
c programming 1-1.pptxc programming 1-1.pptx
c programming 1-1.pptx
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
 
C programming
C programmingC programming
C programming
 
SE-software design.ppt
SE-software design.pptSE-software design.ppt
SE-software design.ppt
 
software process model
software process modelsoftware process model
software process model
 

More from Forrester High School

Database Evaluation
Database EvaluationDatabase Evaluation
Database Evaluation
Forrester High School
 
Testing SQL
Testing SQLTesting SQL
SQL
SQLSQL
Database Query Design
Database Query DesignDatabase Query Design
Database Query Design
Forrester High School
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
Forrester High School
 
Compound Keys
Compound KeysCompound Keys
Compound Keys
Forrester High School
 
Entity Occurrence Diagrams
Entity Occurrence DiagramsEntity Occurrence Diagrams
Entity Occurrence Diagrams
Forrester High School
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
Forrester High School
 
Database Analysis
Database AnalysisDatabase Analysis
Database Analysis
Forrester High School
 
Software Evaluation
Software EvaluationSoftware Evaluation
Software Evaluation
Forrester High School
 
Software Testing
Software TestingSoftware Testing
Software Testing
Forrester High School
 
Python Predefined Functions
Python Predefined FunctionsPython Predefined Functions
Python Predefined Functions
Forrester High School
 
Python Substrings
Python SubstringsPython Substrings
Python Substrings
Forrester High School
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
Forrester High School
 
Records in Python
Records in PythonRecords in Python
Records in Python
Forrester High School
 
Parallel arrays in python
Parallel arrays in pythonParallel arrays in python
Parallel arrays in python
Forrester High School
 
SDD Predefined Functions
SDD Predefined FunctionsSDD Predefined Functions
SDD Predefined Functions
Forrester High School
 
SDD Cconditional Loops
SDD Cconditional LoopsSDD Cconditional Loops
SDD Cconditional Loops
Forrester High School
 
SDD Fixed Loops
SDD Fixed LoopsSDD Fixed Loops
SDD Fixed Loops
Forrester High School
 
SDD Conditional Statements
SDD Conditional StatementsSDD Conditional Statements
SDD Conditional Statements
Forrester High School
 

More from Forrester High School (20)

Database Evaluation
Database EvaluationDatabase Evaluation
Database Evaluation
 
Testing SQL
Testing SQLTesting SQL
Testing SQL
 
SQL
SQLSQL
SQL
 
Database Query Design
Database Query DesignDatabase Query Design
Database Query Design
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Compound Keys
Compound KeysCompound Keys
Compound Keys
 
Entity Occurrence Diagrams
Entity Occurrence DiagramsEntity Occurrence Diagrams
Entity Occurrence Diagrams
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
Database Analysis
Database AnalysisDatabase Analysis
Database Analysis
 
Software Evaluation
Software EvaluationSoftware Evaluation
Software Evaluation
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Python Predefined Functions
Python Predefined FunctionsPython Predefined Functions
Python Predefined Functions
 
Python Substrings
Python SubstringsPython Substrings
Python Substrings
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Records in Python
Records in PythonRecords in Python
Records in Python
 
Parallel arrays in python
Parallel arrays in pythonParallel arrays in python
Parallel arrays in python
 
SDD Predefined Functions
SDD Predefined FunctionsSDD Predefined Functions
SDD Predefined Functions
 
SDD Cconditional Loops
SDD Cconditional LoopsSDD Cconditional Loops
SDD Cconditional Loops
 
SDD Fixed Loops
SDD Fixed LoopsSDD Fixed Loops
SDD Fixed Loops
 
SDD Conditional Statements
SDD Conditional StatementsSDD Conditional Statements
SDD Conditional Statements
 

Recently uploaded

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
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
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
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
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
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
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
 
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)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
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
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
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
 
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.
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

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
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
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
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
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
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
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...
 
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
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

Sub-programs