#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep 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 10:57 PM. Reason: previous topic was lame
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    /dev/null
    Posts
    162
    Rep Power
    18
    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.

IMN logo majestic logo threadwatch logo seochat tools logo