Let's start with these two functions first:
• int lastDig(int num);
This function returns the last digit of num.
If you pass in the value100101101 this function will return 1. You can do this using the modulus (%) operator.
• int removeLast(int num);
This function returns a number without the last digit. For example, removeLast(123) would return 12. The body of this function can be accomplished with one line.
Divide.
Remember, you have a binaryrepresentation in integer form. It's still an integer, in base 10, not base 2.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
You should have a warning about removeLast() . Did you see it? If so, did you ignore it?
What's all that at the end of your post?
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944