Results 1 to 5 of 5

Thread: help please

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    40

    help please

    Code:
    printf("Twenties: %d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS);
    		change_in_cents % CENTS_IN_TWENTY_DOLLARS;
    Im using both division and mod or thats whati think. can someone tell me if im doing something wrong here?

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: help please

    That will be treated as two lines.

    In this line:
    Code:
    printf("Twenties: %d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS);
    the division is performed and the integer result is printed.

    And in the second line, you are just performing the modulus operation but not assigning the result anywhere.

    If you are trying to print both, then something like this can be done:
    Code:
    printf("Twenties: %d.%d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS, change_in_cents % CENTS_IN_TWENTY_DOLLARS);
    I didn't tested the code.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: help please

    @ mattkeem,

    For future reference could you please put a reference to what the question your ask is in the thread title rather than "help please" it will allow users to determine if they would be able to help or not. Also, it would help other people looking for an answer to the same problem.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    40

    Re: help please

    Sorry about that ill reference it better next time. However im not trying to get two outputs but only one. What im trying to do is just say if i purchased simething for 30 dollars and u gave them a 100 dollar bill. You should get 3 twenties and one ten. Tats what im trying to display. I got everything right but the displaying how many twenties and ten i cant seem to do it

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: help please

    Then try something like this:
    Code:
    printf("Twenties: %d\n Tens: %d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS, change_in_cents % CENTS_IN_TWENTY_DOLLARS);

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width