Main Page

Previous Page
Next Page

[Page 238]

Chapter 6. Functions and an Introduction to Recursion

Form ever follows function.

Louis Henri Sullivan

E pluribus unum. (One composed of many.)


O! call back yesterday, bid time return.

William Shakespeare

Call me Ishmael.

Herman Melville

When you call me that, smile!

Owen Wister

Answer me in one word.

William Shakespeare

There is a point at which methods devour themselves.

Frantz Fanon

Life can only be understood backwards; but it must be lived forwards.

Soren Kierkegaard


In this chapter you will learn:

  • To construct programs modularly from functions.

  • To use common math functions available in the C++ Standard Library.

  • To create functions with multiple parameters.

  • The mechanisms for passing information between functions and returning results.

  • How the function call/return mechanism is supported by the function call stack and activation records.

  • To use random number generation to implement game-playing applications.

  • How the visibility of identifiers is limited to specific regions of programs.

  • To write and use recursive functions, i.e., functions that call themselves.

[Page 239]


6.1 Introduction

6.2 Program Components in C++

6.3 Math Library Functions

6.4 Function Definitions with Multiple Parameters

6.5 Function Prototypes and Argument Coercion

6.6 C++ Standard Library Header Files

6.7 Case Study: Random Number Generation

6.8 Case Study: Game of Chance and Introducing enum

6.9 Storage Classes

6.10 Scope Rules

6.11 Function Call Stack and Activation Records

6.12 Functions with Empty Parameter Lists

6.13 Inline Functions

6.14 References and Reference Parameters

6.15 Default Arguments

6.16 Unary Scope Resolution Operator

6.17 Function Overloading

6.18 Function Templates

6.19 Recursion

6.20 Example Using Recursion: Fibonacci Series

6.21 Recursion vs. Iteration

6.22 (Optional) Software Engineering Case Study: Identifying Class Operations in the ATM System

6.23 Wrap-Up



Self-Review Exercises

Answers to Self-Review Exercises


Previous Page
Next Page