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 ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.