CHAP07 - Chapter 7 Functions Chapter7 FUNCTIONS CHAPTER...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
107 Chapter 7 Functions Chapter 7 FUNCTIONS CHAPTER GOALS To be able to write a program that uses functions to reflect the structure of your functional decomposition. To be able to write a module of your own design as a void function. To be able to define a void function to do a specified task. To be able to distinguish between value and reference parameters. To be able to use arguments and parameters correctly. To be able to do the following tasks, given a functional decomposition of a problem: determine what the parameter list should be for each module. determine which parameters should be reference parameters and which should be value parameters. code the program correctly. To be able to define and use local variables correctly. To be able to write a program that uses multiple calls to a single function. CHAPTER OUTLINE I. Functional Decomposition with Void Functions A. When to Use Functions B. Writing Modules as Void Functions May We Introduce : Charles Babbage II. An Overview of User-Defined Functions A. Flow of Control in Function Calls B. Function Parameters III. Syntax and Semantics of Void Functions A. Function Call (Invocation) B. Function Declarations and Definitions 1. Function Prototypes 2. Function Definitions C. Local Variables D. The Return Statement Matters of Style : Naming Void Functions E. Header Files IV. Parameters A. Value Parameters B. Reference Parameters C. An Analogy D. Matching Arguments with Parameters Theoretical Foundations : Argument-Passing Mechanisms E. Designing Functions F. Writing Assertions as Program Comments Matters of Style : Function Preconditions and Postconditions Χ G.Documenting the Direction of Data Flow Matters of Style : Formatting Function Headings Software Engineering Tip: Conceptual Versus Physical Hiding of a Function Implementation V. Problem-Solving Case Study : Comparison of Furniture-Store Sales
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Chapter 7 Functions VI. Testing and Debugging A. The assert library function B. Testing and Debugging Hints VII. Summary GENERAL DISCUSSION There are three major concepts in this chapter: flow of control in a function call, parameter passing, and interface design. The flow of control in a function call is quite a bit different from the flow of control in the other control structures. All of the other control structures are variations of in-line execution: even though flow of control can jump from one place to another, it is always within the given structure and at least within the main function. With a function call, the flow of control jumps to a set of statements that are outside the main function. Furthermore, the code for the other control structures is executed at only one place in the program. Even if a statement is executed many times in a loop, there is still just one point in the program where it is executed. A function, however, may be called from many places in the same program. Thus we have a piece of code that is written in one place but may be executed from multiple places. Parameter passing involves the concepts of parameters and arguments, positional matching, pass by value,
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/13/2011 for the course CSC 140 taught by Professor Lebre during the Spring '04 term at Moraine Valley Community College.

Page1 / 24

CHAP07 - Chapter 7 Functions Chapter7 FUNCTIONS CHAPTER...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online