Chapter 5 - Functions: Outline
Chapter 5 - Functions: Outline
Chapter 5 - Functions: Outline
Outline
5.1 Introduction
5.2 Program Modules in C
5.3 Math Library Functions
5.4 Functions
5.5 Function Definitions
5.6 Function Prototypes
5.7 Header Files
5.8 Calling Functions: Call by Value and Call by Reference
5.9 Random Number Generation
5.10 Example: A Game of Chance
5.11 Storage Classes
5.12 Scope Rules
5.13 Recursion
5.14 Example Using Recursion: The Fibonacci Series
5.15 Recursion vs. Iteration
Enter seed: 67
6 1 4 6 2
1 6 1 6 4
Player rolled 1 + 3 = 4
Point is 4
Player rolled 1 + 4 = 5
Player rolled 5 + 4 = 9
Player rolled 4 + 6 = 10
Player rolled 6 + 3 = 9
Player rolled 1 + 2 = 3
Player rolled 5 + 2 = 7
Player loses
global x is 1 on entering c
global x is 10 on exiting c
global x is 10 on entering c
global x is 100 on exiting c
local x in main is 5
return f( 2 ) + f( 1 )
return f( 1 ) + f( 0 ) return 1
return 1 return 0
Enter an integer: 5
Fibonacci(5) = 5
Enter an integer: 6
Fibonacci(6) = 8
Enter an integer: 10
Fibonacci(10) = 55
Enter an integer: 20
Fibonacci(20) = 6765
Enter an integer: 30
Fibonacci(30) = 832040
Enter an integer: 35
Fibonacci(35) = 9227465