June 16th, 2013, 08:36 PM
(Separating Digits) Write program segments that accomplish each of the following:
a) Calculate the integer part of the quotient when integer a is divided by integer b.
b) Calculate the integer remainder when integer a is divided by integer b.
c) Use the program pieces developed in a) and b) to write a function that inputs an integer
between 1 and 32767 and prints it as a series of digits,with two spaces between each digit.
For example, the integer 4562 should be printed as:
4 5 6 2
actually mind blown at the part says sperate digits
Last edited by mx8manger; June 16th, 2013 at 10:57 PM.
Reason: previous topic was lame
June 17th, 2013, 12:36 AM
You have all the necessary information in the question to build your program. Not sure if you understood the math. Here's a re-iteration using an example:
Originally Posted by mx8manger
int division: 4562 / 10 = 456 # This is step a.
int modulo operation: 4562 % 10 = 2 # This is step b.
int division: 456 / 10 = 45
int modulo operation: 456 % 10 = 6
int division: 45 / 10 = 4
int modulo operation: 45 % 10 = 5
int division: 4 / 10 = 0
int modulo operation: 4 % 10 = 4
In every round, after the modulo operation, you have the last digit in that rounds' number. It's up to you to use a suitable logic to print them as desired.
Try it out and let us know where you're stuck.