COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.

Slides:



Advertisements
Similar presentations
Chapter 3 Top-Down Design with Functions. 3-2 Outline 3.1 BUILDING PROGRAMS FROM EXISING INFORMATION –CASE STUDY: FINDING THE AREA AND CIRCUMFERENCE OF.
Advertisements

Chapter 3 Top-Down Design with Functions Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Copyright © 2002 W. A. Tucker1 Chapter 3 Lecture Notes Bill Tucker Austin Community College COSC 1315.
© 2012 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 3: Top-Down Design with Functions Problem Solving & Program.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3: Top-Down Design with Functions Problem Solving and Program Design.
Top-Down Design with Functions and Classes By Dr. Awad Khalil Computer Science & Engineering Department.
CS 201 Functions Debzani Deb.
Chapter 3 Top-Down Design with Functions Dr. J.-Y. Pan Dept. Comm. Eng. Nat. Chung Cheng Univ.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
CS 201 Functions Debzani Deb.
Top-Down Design with Functions 4 What do programmer’s (not programs!) use as input to the design of a program? –Documentation Problem definition Requirements.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 3: Top-Down Design with Functions Problem Solving & Program.
Topic 4 – Programmer- Defined Functions. CISC 105 – Topic 4 Functions So far, we have only seen programs with one function, main. These programs begin.
COS120 Software Development Using C++ AUBG Fall semester 2010
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
CP104 Introduction to Programming Top-down design with functions Lecture 6-8 __ 1 Top-Down Design with Functions C Library functions Case studies Top-down.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
Lecture 9m: Top-Down Design with Functions COS120 Software Development Using C++ AUBG, COS dept.
1 Introduction to Computers II Lecture 4 Dr. Mehmet Demirer Dr. Seniha Esen Yuksel.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Problem Solving and Program Design in C (5th Edition) by Jeri R. Hanly and Elliot B. Koffman CP 202 Chapter 3 Slides By Dr. Daniyal Alghazzawi.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
Chapter 13 Recursion. Learning Objectives Recursive void Functions – Tracing recursive calls – Infinite recursion, overflows Recursive Functions that.
Top-Down Design with Functions and Classes Chapter 3.
Lecture 9: Top-Down Design with Functions COS120 Software Development Using C++ AUBG, COS dept.
Functions in C Programming Dr. Ahmed Telba. If else // if #include using namespace std; int main() { unsigned short dnum ; cout
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
C++ Functions. Objectives 1. Be able to implement C++ functions 2. Be able to share data among functions 2.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 6 September 17, 2009.
CPSC 230 Computers and Programming I Spring 2003 Dr. Lynn Lambert.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Lecture 8: Top-Down Design with Functions COS120 Software Development Using C++ AUBG, COS dept.
Chapter 3 Top-Down Design with Functions and Classes Lecture Notes Prepared By: Blaise W. Liffick, PhD Department of Computer Science Millersville University.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3: Top-Down Design with Functions and Classes Problem Solving, Abstraction,
Section 4 - Functions. All of the programs that we have studied so far have consisted of a single function, main(). However, having more than one function.
chap3 Chapter 3 Top-Down Design with Functions.
Liang, Introduction to C++ Programming, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 6 Advanced Function Features.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
A FIRST BOOK OF C++ CHAPTER 6 MODULARITY USING FUNCTIONS.
1 MODULAR DESIGN AND ABSTRACTION. 2 SPECIFYING THE DETAILS OF A PROBLEM INTO A RELATED SET OF SMALLER PROBLEMS.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
Chapter 3 : Top Down Design with Functions By Suraya Alias.
Chapter 3 Top-Down Design with Functions. Copyright ©2004 Pearson Addison-Wesley. All rights reserved.3-2 Figure 3.1 Edited Data Requirements and Algorithm.
1 UMBC CMSC 104, Section Fall 2002 Functions, Part 1 of 3 Topics Top-down Design The Function Concept Using Predefined Functions Programmer-Defined.
Fundamental Programming Fundamental Programming Introduction to Functions.
CSIS 113A Lecture 5 Functions. Introduction to Functions  Building Blocks of Programs  Other terminology in other languages:  Procedures, subprograms,
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Programming Fundamentals Enumerations and Functions.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
© 2012 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 3: Top-Down Design with Functions Problem Solving & Program.
Chapter 13 Recursion Copyright © 2016 Pearson, Inc. All rights reserved.
Chapter 9: Value-Returning Functions
CS1001 Programing Fundamental Lecture 5 Top-Down Design with Functions
Function Topic 4.
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Chapter 3: Top-Down Design with Functions and Classes
Lec8.
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Top-Down Design with Functions
Top-Down Design with Functions
Presentation transcript:

COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot Koffman, Course lecturer: Assoc. Prof. Stoyan Bonev, PhD

Lecture 7: Top-Down Design with Functions

3 Lecture Contents: t Top-Down Design t Step-wise refinement and structure charts t Functions topics: –Prototype statement, –Call statement, –Function Definition. t Functions without arguments.

4 Top-Down design There exist problems whose solving algorithms are too complicated, more complex than those already solved. Then developer breaks up problem into sub problems to solve and develop program solution. If necessary some sub problems are to be broken up into sub sub problems and so on. The process described is called Top-Down Design. Illustration based on real problems: to draw figures.

5 Top-Down design Solving problems or creating programs is possible without applying the top-down design approach. Ignoring the top-down design approach results in a program composed of one only main() function full of executable statements. This is a bad, non structured, non flexible style of programming which is not recommended. It is known as “spaghetti code” programming.

6 Top-Down design The process described is called Top-Down Design. Illustration based on concrete problems: t To draw simple diagrams on screen: –To draw a house –To draw a stick figure of a lady

7 Top-Down design – Analysis House is composed of:triangle parallel lines base line Triangle is composed of:intersecting lines base line We need three basic components (building blocks): parallel lines, base line, intersecting lines

8 To draw a house using spaghetti code programming void main() { cout <<endl<< “ /\\ ”; // 3 lines for the roof cout <<endl<< “ / \\ ”; cout <<endl<< “------”; // the ceiling of the room cout <<endl<< “| |”; // parallel lines for the walls cout <<endl<< “| |”; cout <<endl<< “------”; // the floor as a base line }

9 Top-Down design – Design To create a house problem is divided into 3 sub problems: House is composed of: a triangle, parallel lines, base line Triangle is not a building block. It is to be divided into 2 sub sub problems: intersecting lines, base line We need three basic components (building blocks): parallel lines,base line,intersecting lines

10 Top–Down design of a house House Problem TriangleParallel_lines Base_line Sub-problems Intersect_lines Base_line Sub-sub-problems The figure shown is called a structure chart.

11 Top-Down design – Analysis Stick figure is composed of:circle triangle intersecting lines Triangle is composed of:intersecting lines base line We need totally four basic components (building blocks): parallel lines,base line,intersecting lines, circle

12 Introduction to the Function concept

13 Top-Down design – Implementation We need a program feature (module, unit, procedure, sub program, routine) to do the job for the basic components, specified as leaves of the tree for the structure chart. Such a program feature in C++ is called a function.

14 Top-Down design – Implementation Introduction To functions without arguments and no return value

15 Top-Down design – Implementation Function implementing 1 st basic component (solving a sub sub problem) “to draw a base line” void DrawBase(void) { cout << endl << “ ”; }

16 Top-Down design – Implementation Function implementing 2 nd basic component (solving a sub sub problem) “to draw parallel lines” void DrawParallel(void) { cout << endl << “| |”; }

17 Top-Down design – Implementation Function implementing 3 rd basic component (solving a sub sub problem) “to draw intersecting lines” void DrawIntersect(void) { cout << endl << “ /\\ “; cout << endl << “/ \\”; }

18 Top-Down design – Implementation Functions implementing all basic components void DrawParallel(void)// draw parallel lines { cout << endl << “| |”; } void DrawBase(void)// draw a base line { cout << endl << “ ”; } void DrawIntersect(void)// draw intersecting lines { cout << endl << “ /\\ “; cout << endl << “/ \\”; }

19 Top-Down design – Further Implementation Function to draw a triangle (solving a sub problem). It is based on calling (activating) functions for basic components. void DrawTriangle(void) { DrawIntersect(); DrawBase(); }

20 Top-Down design – Final Implementation Function to draw a house (solving a problem). It is based on calling (activating) functions for basic components (sub sub problems) and functions (solving sub problem) void DrawHouse(void) { DrawTriangle(); DrawParallel(); DrawBase(); }

21 Top-Down design – the main() function #include using namespace std; … void main() //source text of function main { DrawHouse(); } …

22 Why to use functions? See next two slides Problem: Draw a house #include using namespace std; void main() //source text of function main { DrawHouse(); }...

23 Why to use functions? Problem: Draw two houses. Solution: We add one only more statement to duplicate the function call #include using namespace std; void main()// source text of function main { DrawHouse(); }...

24 Why to use functions? Problem: Draw three houses. Solution: We add two more statements to triple the function call #include using namespace std; void main()// source text of function main { DrawHouse(); }...

25 Details on functions Three important topics when dealing with functions:  prototype (signature) statement  function call statement  function definition

26 Example Function prototype: void DrawHouse(void); Function call: DrawHouse(); Function definition: void DrawHouse(void) { DrawTriangle(); DrawParallel(); DrawBase(); }

27 The entire program – have a look at the handout #include using namespace std; void DrawHouse(void); void DrawTriangle(void); void DrawParallel(void); void DrawBase(void); void DrawIntersect(void); void main(){ DrawHouse();} void DrawHouse(void){DrawTriangle(); DrawParallel(); DrawBase();} void DrawTriangle(void){ DrawIntersect(); DrawBase();} void DrawParallel(void){ cout<<“\n| |”; cout<< “\n| |”;} void DrawBase(void){ cout << “\n ”;} void DrawIntersect(void){ cout<< “\n /\\“;cout<<“\n / \\ “; cout<< “\n/ \\”; }

28 Two important topics t Placement of Functions in a Program t Order of Execution of Functions

29 Placement of Functions in a Program The previous slide shows the complete program with function subprograms. The subprogram prototypes precede the main() function (after any #include directives) and the subprogram definitions follow the main() function. The relative order of the function definitions does not affect their order of execution; that is determined by the order of execution of the function call statements.

30 Order of Execution of Functions The prototypes for the function subprograms appear before main() function, so the compiler processes the function prototypes before it translates the main() function. The information in each prototype lets the compiler correctly translate a call to that function. The compiler translates a function call statement as a transfer of control (or unconditional branch) to that function. After compiling the main() function, the compiler translates each function subprogram. During translation, when the compiler reaches the end of the function body, it inserts a machine language statement that causes a transfer of control (again unconditional branch) back from the function to the calling statement.

31 Summary on functions Prototype: void fname(void); Call: fname( ); Definition: void fname(void) { }

32 Conclusion on functions: Why to use functions? (two important reasons) 1. Dividing a program into functions is one of the major principles of structured programming. 2. Using functions results in reduced program size.

33 Valid reasons to create a routine: t Reduce complexity –“Properly designed functions permit to ignore how a job’s done. Knowing what is done is sufficient.” B.Kernighan & D.Ritchie –“A function provides a convenient way to encapsulate some computation, which can then be used without worrying about its implementation. ” B.Kernighan & D.Ritchie t Avoid duplicate code –Usually functions are specified to be called many times.

34 Exercise 7.1 Using functions Build and run a program: To draw a stick figure

35 Exercise 7.2 Using functions Build and run a program: to display block letters. Write a program to display the initial letter of your first name as a block letter using a function like this: void print_x(void) {... }

36 Before lecture end Lecture: Top-Down Design using Functions More to read: Friedman/Koffman, Chapter 03

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3: Top-Down Design with Functions and Classes Problem Solving, Abstraction, and Design using C++ 5e by Frank L. Friedman and Elliot B. Koffman

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Building Programs with Existing Information Analysis and design phases provide much information to help plan and complete a program Can start with data requirements to develop constant and variable declarations Use the algorithm as a first step in coding executable statements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 39 Case Study: Finding the Area and Circumference of a Circle Problem statement Get the radius of a circle. Compute and display the circle’s area and circumference. Analysis –input is the circle’s radius –need calculation for the area –need calculation for the circumference

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 40 Case Study: Data Requirements Problem Constant PI = Problem input float radius// radius of a circle Problem output float area // area of a circle float circum // circumference of a circle

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 41 Case Study: Formulas Area of a circle =   radius 2 Circumference of a circle = 2    radius

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 42 Case Study: Design - Algorithm 1. Get the circle radius 2. Compute the area of circle 3. Compute the circumference of circle 4. Display area and circumference

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 43 Case Study: Design - Algorithm 1. Get the circle radius 2. Compute the area of circle 2.1 Assign PI * radius * radius to area 3. Compute the circumference of circle 3.1 Assign 2 * PI * radius to circum 4. Display area and circumference

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 44 Listing 3.2 Outline of area and circumference program

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 45 Listing 3.3 Finding the area and circumference of a circle

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 46 Listing 3.3 Finding the area and circumference of a circle (continued)

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 47 Case Study: Testing Radius of 5.0 Should get area of … Should get circumference of

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 48 Case Study: Weight of Flat Washers Problem statement You work for a hardware company that manufactures flat washers. To estimate shipping costs, you company needs a program that computes the weight of a specified quantity of flat washers.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 49 Case Study: Weight of Flat Washers Analysis –flat washer is like a small donut –need to know rim area, thickness, density –rim area will be computed from knowing the washer’s outer and inner diameters.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 50 Case Study: Data Requirements Problem Constant PI = Problem inputs float holeDiameter // diameter of hole float edgeDiameter // diameter of outer edge float thickness// thickness of washer float density// density of material used float quantity// number of washers made

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 51 Case Study: Data Requirements Problem output float weight// weight of batch of washers Program Variables float holeRadius// radius of hole float edgeRadius// radius of outer edge float rimArea// area of rim float unitWeight// weight of 1 washer

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 52 Case Study: Formulas Area of circle =   radius 2 Radius of circle = diameter / 2 Rim area = area of outer circle - area of hole Unit weight = rim area  thickness  density

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 53 Listing 3.4 Washer program

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 54 Listing 3.4 Washer program (continued)

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 55 Case Study: Testing Input data inner diameter of 1.2 outer diameter of 2.4 thickness of 0.1 material density of 7.87 quantity in batch of 1000 Should produce expected weight of batch of grams

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Top-Down Design and Structure Charts Top-down design –process to break down complex problem into smaller, simpler subproblems –similar to development of an algorithm Structure chart –graphical representation of relationship of subproblems

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 57 Case Study: Simple Figures Problem statement Draw some simple diagrams on the screen, e.g. a house and a female stick figure. Analysis –house is formed by displaying a triangle without its base, on top of a rectangle –stick figure consists of a circular shape, a triangle, and a triangle without its base. –4 basic shapes: circle, base line, parallel lines, intersecting lines

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 58 Figure 3.4 House and stick figure

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 59 Case Study: Design - Algorithm (no real data involved, so skip Data Requirements) For stick figure: 1.Draw a circle. 2.Draw a triangle. 3.Draw intersecting lines.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 60 Case Study: Design - Algorithm (no real data involved, so skip Data Requirements) For stick figure: 1.Draw a circle. 2.Draw a triangle. 2.1 Draw intersecting lines. 2.2 Draw a base line. 3.Draw intersecting lines.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 61 Case Study: Structure Chart Original Problem Detailed subproblems Level 0 Level 1 Level 2 Subproblems

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Functions without Arguments Functions important part of top-down design main( ) is a function called by the OS Form of call:fname( ); Example:drawCircle( ); Interpretation:the function fname is activated. After fname finishes execution, the program statement that follows the function call will be executed next.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 63 Some Notes on Functions Don’t need to know details about how a function is implemented to know how to call. E.g. y = sqrt(x);// don’t know how sqrt implemented Do know how function is used (called). Empty parentheses indicate no arguments (more on this later).

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 64 Function Prototype Declares the function to the compiler Appears before function main. Tells compiler the function’s type, its name, and information about arguments.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 65 Function Prototype (no Arguments) Form:ftype fname( ); Example:void skipThree( ); Interpretation: identifier fname is declared to be the name of a function. The identifier ftype specifies the data type of the function result. Ftype of void indicates the function does not return a value.

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 66 Function Definitions Specifies the function’s operations Function header similar to function prototype Function body contains declarations for local variables and constants and executable statements Prototypes precede main function (after #include directives) Function definitions follow main function

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 67 Function Definition (no arguments) Syntax:ftype fname( ) { local declarations executable statements }

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 68 Function Definition (no arguments) Example: // Displays block-letter H void printH( ) { cout << “** **” << endl; cout << “******” << endl; cout << “** **” << endl; }// end printH

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 69 Order of Execution int main( ) { drawCircle( ); drawTriangle( ); drawIntersect( ); return 0; } void drawCircle( ) { cout << “ * “ << endl; cout << “ * * “ << endl; //return to calling function } // end drawCircle

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 70 Notes on Function Execution Execution always begins at first statement of main function When a function is called –space is set aside for function variables –statements of function are executed –control returns to statement following call –function ends with space released

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 71 Function Advantages Team assignments on large project Simplify tasks Each function is a separate unit Top-down approach Reuse (e.g. drawTriangle) Procedural abstraction Information hiding

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 72 Displaying User Instructions Simple functions (no arguments, no return value) are of limited use Useful for displaying instructions to user E.g. void instruct( );// prototype … instruct( );//function call

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 73 // Displays instructions to user of area/circumference program void instruct () { cout << "This program computes the area and " << endl; cout << "circumference of a circle. " << endl << endl; cout << "To use this program, enter the radius of the " << endl; cout << "circle after the prompt" << endl; cout << "Enter the circle radius: " << endl << endl; cout << "The circumference will be computed in the same” << endl; cout << "units of measurement as the radius. The area " << endl; cout << "will be computed in the same units squared." << endl << endl; } Figure 3.10 Function instruct

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 74 Functions with Input Arguments Functions used like building blocks Build systems one function at a time –E.g. stereo components Use function arguments to carry information into function subprogram (input arguments) or to return multiple results (output arguments)

75 Thank You For Your Attention!