Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
June 16th, 2013, 09:36 PM
 mx8manger
Registered User

Join Date: Jun 2013
Posts: 1
Time spent in forums: 1 h 55 m 47 sec
Reputation Power: 0
seperate digits

(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 11:57 PM. Reason: previous topic was lame

#2
June 17th, 2013, 01:36 AM
 noobie1000
Contributing User

Join Date: May 2013
Location: /dev/null
Posts: 146
Time spent in forums: 1 Day 10 h 49 m 41 sec
Reputation Power: 18
Quote:
 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:

Round 1:
int division: 4562 / 10 = 456 # This is step a.
int modulo operation: 4562 % 10 = 2 # This is step b.

Round 2:
int division: 456 / 10 = 45
int modulo operation: 456 % 10 = 6

Round 3:
int division: 45 / 10 = 4
int modulo operation: 45 % 10 = 5

Round 4:
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.

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Reply_to_whoever have the currency converter issu