When finished developing your code click here to compare your solution to mine. After you have completed your own solution, reviewing another is often helpful in learning how to improve your programming skills.

Write a function named printUp() using recursion to print numbers from 0 to n.

Example output:

Counting up: 0 1 2 3

Hint: Remember the discussion of pre- and post recursion. You only need to move the output statement of the previous problem to solve this one. See Try It: Exploring Pre- and Post-Recursion for more information.

Write a function using recursion named printStars() that receives a single int parameter and returns nothing. It the parameter value is greater than zero, the function prints to the console the given number of asterisks; otherwise it does nothing. For instance, calling printStars(8) displays: ******** (8 asterisks).

Example output:

Printing stars: ***

We have a number of bunnies and each bunny has two big floppy ears. Write a non-member function named bunnyEars() that computes the total number of ears for zero or more bunnies recursively without loops, multiplication or division.

We want to write a function named digits() which finds the number of digits needed to represent an integer. For example, digits(1234) is 4 because 1234 has four digits (1, 2, 3, and 4). Here is a trace of the function calls:

Write a function using recursion that displays a string in reverse. Do not use arrays, loops or additional strings.
Example output:

Enter a string: abcdef
String reversed: fedcba

Recall from lesson 3.2.6 that you can access part of a string using the substr() function. Also, you can determine the length of a string using the length() function. Also, you can use square bracket notation to access a single character as discussed in lesson 6.2.2.

Also note that your recursive function will need two parameters: one for the string and one for the index of the string.