SlideShare a Scribd company logo
1 of 65
 
Chapter 5 Functions for All Subtasks Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
Overview ,[object Object],[object Object],[object Object],[object Object],Slide 5-
5.1 void  Functions Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
void-Functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
[object Object],[object Object],[object Object],[object Object],[object Object],void-Function Definition Slide 5-  Display 5.1
Using a void-Function ,[object Object],[object Object],[object Object],[object Object],Slide 5-
void-Function Calls ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
[object Object],[object Object],Example:  Converting Temperatures Slide 5-  Display 5.2 (1) Display 5.2 (2)
[object Object],[object Object],[object Object],[object Object],void-Functions Why Use a Return? Slide 5-  Display 5.3
The Main Function ,[object Object],[object Object],[object Object],Slide 5-
Section 5.1 Conclusion ,[object Object],[object Object],[object Object],[object Object],Slide 5-
5.2 Call-By-Reference Parameters Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
Call-by-Reference Parameters ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
[object Object],[object Object],[object Object],Call-by-Reference Example Slide 5-  Display 5.4 (1) Display 5.4 (2)
[object Object],[object Object],[object Object],Call-By-Reference Details Slide 5-  Display 5.5 (1) Display 5.5 (2)
[object Object],[object Object],[object Object],[object Object],Call Comparisons Call By Reference vs Value Slide 5-  Memory Name Location Contents age 1001 34   initial 1002 A hours 1003 23.5 1004
Example:  swap_values ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
Mixed Parameter Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
[object Object],[object Object],[object Object],[object Object],Choosing Parameter Types Slide 5-  Display 5.6
[object Object],[object Object],[object Object],[object Object],[object Object],Inadvertent Local Variables Slide 5-  Display 5.7
Section 5.2 Conclusion ,[object Object],[object Object],[object Object],[object Object],Slide 5-
5.3 Using Procedural Abstraction Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
Using Procedural Abstraction ,[object Object],[object Object],[object Object],Slide 5-
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Functions Calling Functions Slide 5-  Display 5.8 (1) Display 5.8 (2)
Pre and Postconditions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
swap_values revisited ,[object Object],Slide 5-
Function celsius ,[object Object],Slide 5-
Why use preconditions and postconditions? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
Case Study Supermarket Pricing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
Supermarket Pricing: Problem Analysis ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
Supermarket Pricing: Function get_input ,[object Object],Slide 5-
Supermarket Pricing: Function price ,[object Object],Slide 5-
Supermarket Pricing: Function give_output ,[object Object],Slide 5-
Supermarket Pricing: The main function ,[object Object],Slide 5-
Supermarket Pricing: Algorithm Design -- price ,[object Object],[object Object],[object Object],Slide 5-
Supermarket Pricing: Constants for The price Function ,[object Object],[object Object],[object Object],[object Object],Slide 5-
[object Object],[object Object],[object Object],Supermarket Pricing: Coding The price Function Slide 5-  Display 5.9 (1) Display 5.9 (2) Display 5.9 (3)
Supermarket Pricing : Program Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
Section 5.3 Conclusion ,[object Object],[object Object],[object Object],[object Object],Slide 5-
5.4 Testing and Debugging Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
[object Object],[object Object],[object Object],[object Object],[object Object],Testing and Debugging Functions Slide 5-  Display 5.10 (1) Display 5.10 (2)
[object Object],[object Object],[object Object],[object Object],[object Object],Stubs Slide 5-  Display 5.11 (1) Display 5.11 (2)
Rule for Testing Functions ,[object Object],[object Object],Slide 5-
Section 5.4 Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 5-
Chapter 5 -- End Slide 5-
Display 5.1  Slide 5-  Back Next
Display 5.2  (1/2) Slide 5-  Back Next
Display 5.2 (2/2) Slide 5-  Back Next
Display 5.3 Slide 5-  Back Next
Display 5.4  (1/2) Slide 5-  Back Next
Display 5.4 (2/2) Slide 5-  Back Next
Display 5.5 (1/2) Slide 5-  Back Next
Display 5.5 (2/2) Slide 5-  Back Next
Display 5.6 Slide 5-  Back Next
Display 5.7 Slide 5-  Back Next
Display 5.8  (1/2) Slide 5-  Next Back
Display 5.8  (2/2) Slide 5-  Back Next
Display 5.9 (1/3) Slide 5-  Back Next
Display 5.9  (2/3) Slide 5-  Back Next
Display 5.9 (3/3) Slide 5-  Back Next
Display 5.10  (1/2) Slide 5-  Next Back
Display 5.10 (2/2) Slide 5-  Back Next
Display 5.11  (1/2) Slide 5-  Back Next
Display 5.11 (2/2) Slide 5-  Back Next

More Related Content

What's hot

Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
Deepak Singh
 

What's hot (19)

Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
Function in C
Function in CFunction in C
Function in C
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
user defined function
user defined functionuser defined function
user defined function
 
Function & Recursion
Function & RecursionFunction & Recursion
Function & Recursion
 
predefined and user defined functions
predefined and user defined functionspredefined and user defined functions
predefined and user defined functions
 
C functions
C functionsC functions
C functions
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program Organization
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
 
Savitch ch 11
Savitch ch 11Savitch ch 11
Savitch ch 11
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
User Defined Functions
User Defined FunctionsUser Defined Functions
User Defined Functions
 
Functions assignment
Functions assignmentFunctions assignment
Functions assignment
 
Parameter passing to_functions_in_c
Parameter passing to_functions_in_cParameter passing to_functions_in_c
Parameter passing to_functions_in_c
 
Functions in C
Functions in CFunctions in C
Functions in C
 

Viewers also liked (20)

Savitch Ch 04
Savitch Ch 04Savitch Ch 04
Savitch Ch 04
 
Chapter no 1
Chapter no 1Chapter no 1
Chapter no 1
 
Savitch Ch 17
Savitch Ch 17Savitch Ch 17
Savitch Ch 17
 
Savitch Ch 11
Savitch Ch 11Savitch Ch 11
Savitch Ch 11
 
Savitch Ch 13
Savitch Ch 13Savitch Ch 13
Savitch Ch 13
 
Savitch Ch 07
Savitch Ch 07Savitch Ch 07
Savitch Ch 07
 
Savitch Ch 01
Savitch Ch 01Savitch Ch 01
Savitch Ch 01
 
Savitch ch 022
Savitch ch 022Savitch ch 022
Savitch ch 022
 
Savitch Ch 15
Savitch Ch 15Savitch Ch 15
Savitch Ch 15
 
Savitch Ch 03
Savitch Ch 03Savitch Ch 03
Savitch Ch 03
 
Savitch Ch 18
Savitch Ch 18Savitch Ch 18
Savitch Ch 18
 
Savitch ch 04
Savitch ch 04Savitch ch 04
Savitch ch 04
 
Savitch Ch 08
Savitch Ch 08Savitch Ch 08
Savitch Ch 08
 
Savitch Ch 14
Savitch Ch 14Savitch Ch 14
Savitch Ch 14
 
Savitch Ch 06
Savitch Ch 06Savitch Ch 06
Savitch Ch 06
 
Savitch Ch 12
Savitch Ch 12Savitch Ch 12
Savitch Ch 12
 
Savitch c++ ppt figs ch1
Savitch c++ ppt figs ch1Savitch c++ ppt figs ch1
Savitch c++ ppt figs ch1
 
Savitch ch 01
Savitch ch 01Savitch ch 01
Savitch ch 01
 
Savitch Ch 10
Savitch Ch 10Savitch Ch 10
Savitch Ch 10
 
Savitch ch 16
Savitch ch 16Savitch ch 16
Savitch ch 16
 

Similar to Savitch Ch 05

INTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docx
INTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docxINTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docx
INTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docx
mariuse18nolet
 
Functions in Python.pdfnsjiwshkwijjahuwjwjw
Functions in Python.pdfnsjiwshkwijjahuwjwjwFunctions in Python.pdfnsjiwshkwijjahuwjwjw
Functions in Python.pdfnsjiwshkwijjahuwjwjw
MayankSinghRawat6
 

Similar to Savitch Ch 05 (20)

Savitch Ch 04
Savitch Ch 04Savitch Ch 04
Savitch Ch 04
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
 
Function
Function Function
Function
 
Chapter 5 - Modular Programming.pdf
Chapter 5 - Modular Programming.pdfChapter 5 - Modular Programming.pdf
Chapter 5 - Modular Programming.pdf
 
Ch07.pdf
Ch07.pdfCh07.pdf
Ch07.pdf
 
C programming slide-6
C programming slide-6C programming slide-6
C programming slide-6
 
Functions in C++.pdf
Functions in C++.pdfFunctions in C++.pdf
Functions in C++.pdf
 
CHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptxCHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptx
 
User Defined Functions in C
User Defined Functions in CUser Defined Functions in C
User Defined Functions in C
 
INTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docx
INTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docxINTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docx
INTROPhase 4- Vanilla Bond ValuationProfessor Angela GarrettFI.docx
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Functions in c language
Functions in c languageFunctions in c language
Functions in c language
 
Function
FunctionFunction
Function
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
FUNCTIONS.pptx
FUNCTIONS.pptxFUNCTIONS.pptx
FUNCTIONS.pptx
 
Functions in Python.pdfnsjiwshkwijjahuwjwjw
Functions in Python.pdfnsjiwshkwijjahuwjwjwFunctions in Python.pdfnsjiwshkwijjahuwjwjw
Functions in Python.pdfnsjiwshkwijjahuwjwjw
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
c.p function
c.p functionc.p function
c.p function
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in C
 

More from Terry Yoast

More from Terry Yoast (20)

9781305078444 ppt ch12
9781305078444 ppt ch129781305078444 ppt ch12
9781305078444 ppt ch12
 
9781305078444 ppt ch11
9781305078444 ppt ch119781305078444 ppt ch11
9781305078444 ppt ch11
 
9781305078444 ppt ch10
9781305078444 ppt ch109781305078444 ppt ch10
9781305078444 ppt ch10
 
9781305078444 ppt ch09
9781305078444 ppt ch099781305078444 ppt ch09
9781305078444 ppt ch09
 
9781305078444 ppt ch08
9781305078444 ppt ch089781305078444 ppt ch08
9781305078444 ppt ch08
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
 
9781305078444 ppt ch04
9781305078444 ppt ch049781305078444 ppt ch04
9781305078444 ppt ch04
 
9781305078444 ppt ch03
9781305078444 ppt ch039781305078444 ppt ch03
9781305078444 ppt ch03
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
 
9781305078444 ppt ch01
9781305078444 ppt ch019781305078444 ppt ch01
9781305078444 ppt ch01
 
9781337102087 ppt ch13
9781337102087 ppt ch139781337102087 ppt ch13
9781337102087 ppt ch13
 
9781337102087 ppt ch18
9781337102087 ppt ch189781337102087 ppt ch18
9781337102087 ppt ch18
 
9781337102087 ppt ch17
9781337102087 ppt ch179781337102087 ppt ch17
9781337102087 ppt ch17
 
9781337102087 ppt ch16
9781337102087 ppt ch169781337102087 ppt ch16
9781337102087 ppt ch16
 
9781337102087 ppt ch15
9781337102087 ppt ch159781337102087 ppt ch15
9781337102087 ppt ch15
 
9781337102087 ppt ch14
9781337102087 ppt ch149781337102087 ppt ch14
9781337102087 ppt ch14
 
9781337102087 ppt ch12
9781337102087 ppt ch129781337102087 ppt ch12
9781337102087 ppt ch12
 
9781337102087 ppt ch11
9781337102087 ppt ch119781337102087 ppt ch11
9781337102087 ppt ch11
 

Recently uploaded

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

Savitch Ch 05