Lecture Twelve

31 August 98


Click here to start


Table of Contents

Using Functions

Argument passing, return value, and local variables

Real World Applications: Monte Carlo Integration

Solution

Sample Input/Output

C Implementation

The main()

The function

Recursion

Example

Factorial, the main() function

The Recursive Factorial Function

A Non-recursive Factorial Function

How does the recursive function execute?

Tower of Hanoi

Tower of Hanoi, the recursive idea

In Pictures

The main() Program

Hanoi function

Output for the case of 3 disks

Reading/Home Working

Author: NUS

Email: cscwjs@nus.edu.sg

Home Page: http://www.cz3.nus.edu.sg/~wangjs/CZ1102/cz1102.html

Download presentation source