December 2001
Beginner
976 pages
22h 4m
English
![]() | Applying It |
Try to complete the following exercises by yourself.
Change exercise 1 from Chapter 9, “Control Statements,” to calculate the factorial using a function that calls itself—a recursive function. Hint: Define a function called Factorial with one argument n, and have it compute the factorial of the argument by calling itself. You will need to specify a condition to end the recursion.
Create and test a function that “pads” a String s with spaces up to a specified length n. If the length of the string passed in exceeds n, trim it to be at most n characters. The function should have an optional ...
Read now
Unlock full access