Absolute C++ (4th Edition) part 56. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Recursive void Functions 557 which is equivalent to newWriteVertical O That in turn will stop to execute the recursive call newWriteVertical 0 10 which is also equivalent to newWriteVertical 0 and that will produce another recursive call to again execute the same recursive function call newWriteVertical 0 and so on forever. Since the definition of newWriteVertical has no stopping case the process will proceed forever or until the computer runs out of resources . Self-Test Exercises 1. What is the output of the following program include iostream using std cout void cheers int n int main cheers 3 return 0 void cheers int n if n 1 cout Hurray n else cout Hip cheers n - 1 2. Write a recursive void function that has one parameter that is a positive integer and that writes out that number of asterisks to the screen all on one line. 3. Write a recursive void function that has one parameter that is a positive integer. When called the function writes its argument to the screen backward. That is if the argument is 1234 it outputs the following to the screen 4321 558 Recursion 4. Write a recursive void function that takes a single int argument n and writes the integers 1 2 . . . n. 5. Write a recursive void function that takes a single int argument n and writes integers n n-1 . . . 3 2 1. Hint Notice that you can get from the code for Exercise 4 to that for this exercise or vice versa by an exchange of as little as two lines. stack last-in first-out STACKS FOR RECURSION To keep track of recursion and a number of other things most computer systems make use of a structure called a stack. A stack is a very specialized kind of memory structure that is analogous to a stack of paper. In this analogy there is an inexhaustible supply of extra blank sheets of paper. To place some information in the stack it is written on one of these sheets of paper and placed on top of the stack of papers. To place more information in the stack a clean sheet of paper is taken the information is .