Lesson 18-1: Check Prelab Exercises
Recursion | 457
Name __________________________________________ Date _______________________
Section _________________________________________
Note that the function return value is assigned at the end of the execution of each call.
Exercise 1:
Call n Function Value Returned
Nonrecursive Call 5 120
1st Recursive Call 4 24
2nd Recursive Call 3 6
3rd Recursive Call 2 2
4th Recursive Call 1 1
5th Recursive Call 0 1
Exercise 2:
Call listPtr Function Value Returned
Nonrecursive Call
14
1st Recursive Call
23
2nd Recursive Call
32
3rd Recursive Call
41
4th Recursive Call NULL 0
78828_CH18_DaleLab 5/22/09 7:55 AM Page 457

Get A Laboratory Course in C++, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.