Monday, October 31, 2011

Lab 6 - reverse digits function

You are to complete exercise 5, p 341, writing a program which contains a user-defined function, reverseDigit. This is its header:

   int reverseDigit(int value)

This problem should seem familiar: lab 5 required you to reverse the digits of an integer as well. The difference is that in the previous program you merely had to strip off the digits of the input number one at a time, working from right to left, and print them at the command line; in this program, not only do you need to reverse the digits, you need to store the digits as an integer. You will be doing the work in your user-defined function and returning the reversed number to main.

For example, say the user inputs the number 687. Your reverseDigit function must return 786. Your reverseDigit function must be capable of handling negative integers as well as positive ones. If the user inputs -13, your program should display -31 as the reversed number.

Sample Output
Here is a screenshot of my code running.

Reverse and Store Digits output

Refer to the deliverables post for comment formatting and required program identification information.

Due Date:
Sunday, November 6th, 6:00pm