< previous page page_1146 next page >

Page 1146
Call 4: number is 1. Because number is not equal to 0, execution of this call pauses until the recursive call with an actual parameter of (number / 2) has completed.
Call 5: number is 0. Execution of this call to Convert is complete. Control returns to the preceding call.
Call 4: Execution of this call resumes with the statement following the recursive call to Convert. The value of number % 2 (which is 1) is printed. Execution of this call is complete.
Call 3: Execution of this call resumes with the statement following the recursive call to Convert. The value of number % 2 (which is 0) is printed. Execution of this call is complete.
Call 2: Execution of this call resumes with the statement following the recursive call to Convert. The value of number % 2 (which is 1) is printed. Execution of this call is complete.
Call 1: Execution of this call resumes with the statement following the recursive call to Convert. The value of number % 2 (which is 0) is printed. Execution of this call is complete. Because this is the nonrecursive call, execution resumes with the statement immediately following the original call.
Figure 19-6 shows the execution of the Convert function with the values of the actual parameters.
1146-01.gif
Figure 19-6
Execution of
Convert(10)

 
< previous page page_1146 next page >