June 17th, 2013, 01:36 AM
Join Date: May 2013
Originally Posted by mx8manger
(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
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:
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.