Question: -Write a recursive function that takes a nonnegative integer as an argument and prints each digit of that integer out (in order from left or
-Write a recursive function that takes a nonnegative integer as an argument and prints each digit of that integer out (in order from left or right) on a separate line. The base case is one in which the integer contains only one digit. Note the following when considering the general case: 1) an integer number n divided by the integer 10 is the number with the last digit removed, and 2) n % 10 is the last digit of n. Write a program to test your function. -----Write two functions that call each other to determine whether a nonnegative number n is odd or even. (Note that the normal approach is simply to calculate n % 2; however, this program is provided to illustrate how indirect recursion works.) Assume that the integer 0 is even. Therefore, the base case for the even function is the number 0, which returns true, and the base case for the odd function is also the number 0, which returns false. The even function will call odd(n-1) recursively, and the odd function will call even(n-1) recursively. Test your functions in a program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
