Thread: Helppp!!

  1. #16
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    but for some reason it always give 0% for the grade.
    That is because in the following line all of your values are integer values.
    Code:
    percent = (correct/20) * 100;
    So when you divide correct by 20 you get a number that is greater than zero but smaller than one. And using integer math this will evaluate to zero. And since zero times anything is zero you will always have a zero answer. To fix this problem insure that at least one variable is a floating point value. So for your calculation change it to:
    Code:
     percent = (correct / 20.0) * 100.0;
    Also insure percent is a floating point type.

    Jim

  2. #17
    Registered User
    Join Date
    Mar 2011
    Posts
    18
    Oh. Wow. That worked. Thanks a lot man!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin.get() Helppp!!!
    By yukapuka in forum C++ Programming
    Replies: 6
    Last Post: 05-03-2008, 11:57 AM
  2. helppp in bank databse
    By neha007 in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2007, 09:43 AM
  3. Helppp
    By GQgirl in forum C Programming
    Replies: 6
    Last Post: 11-23-2006, 05:03 PM
  4. Modem programming helppp amateur!!
    By Siagal in forum Windows Programming
    Replies: 4
    Last Post: 10-12-2001, 03:02 AM
  5. Modem programming helppp amateur!!
    By Siagal in forum C Programming
    Replies: 4
    Last Post: 10-10-2001, 05:12 AM