Programming Exercises

   


1:

Write a recursive method call Count that takes a positive argument of type int. The Count method must be able to count the number of digits in the provided argument. For example, 2319 has four digits. Hint: If the number is less than 10, we have a base case (one digit); if the number of digits is 10 or greater, we can express the number of digits as 1+ the count of (number/10).

2:

Write a recursive method that prints out the name (with text) of each digit in a number provided. For example, if the number 2319 is provided, the method should print: two three one nine. hint: To print 2319, we can print 231 followed by the last digit 9. We can isolate 231 with the calculation 2319/10, and we can isolate 9 with 2319 % 10. A seperate method can be used to print a single digit as a word.


   


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net