O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.10. Exercises

1:Write itoh() (Listing 3.3 on page 91) without recursion, and use the same main() program from the chapter. What are the advantages and disadvantages of each version?
2:The recursive version of itoh() (Listing 3.3 on page 91) and Exercise 1 both have void return values because each routine displays the result. Modify the recursive version of itoh() to return a character string pointer to the caller. Use the following program to test your solution.
Listing 3.21. Program with integer-to-hexadecimal conversion
 // itoh2.C - recursive integer-to-hex conversion, returns buffer #include <iostream.h> #include <stdlib.h> int main(int argc, const char *argv[]) { unsigned int num; char *itoh(unsigned int); // returns character pointer if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required