Thread: Homework help

  1. #16
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by arsenalftw067 View Post
    the program now shows how many times I rolled each number but no th
    It doesn't show what now?

  2. #17
    Registered User
    Join Date
    Mar 2012
    Posts
    16
    Not the percentage of each rolled number

  3. #18
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I see. You use expressions like this:

    (num3/times_rolled)*100

    The major issue is that since both times_rolled and num3 (but numN in general applies to this) are integers, integer division takes place. If you want an answer other than zero, you need to cast one of the dividing terms to say, float, to yield percentages.

  4. #19
    Registered User
    Join Date
    Mar 2012
    Posts
    16
    So I would have to have the num1 num2 etc all in floats?

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No, it means you should do
    (static_cast<float>(num3)/times_rolled)*100
    Now num3 will be converted into a float in this calculation which means you will do a floating point division which will keep the decimals.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework Help
    By andrei1599 in forum C# Programming
    Replies: 1
    Last Post: 02-06-2011, 09:38 PM
  2. My homework
    By Bala in forum C++ Programming
    Replies: 5
    Last Post: 06-12-2010, 11:11 AM
  3. help about homework
    By agathery in forum C Programming
    Replies: 27
    Last Post: 05-19-2010, 09:17 PM
  4. homework
    By misplaced in forum C++ Programming
    Replies: 18
    Last Post: 10-04-2004, 06:56 AM
  5. I want homework!
    By Tynnhammar in forum C++ Programming
    Replies: 9
    Last Post: 09-29-2004, 02:49 PM