Thread: help with arrays and loops

  1. #46
    Join Date
    Aug 2010
    Ontario Canada
    #include <stdio.h>
    #include <math.h>
    float calculateCharges(float hours);
    //const int NUMBER_OF_CARS= 8;
    #define NUMBER_OF_CARS 8
    int main(void)
     int cars[NUMBER_OF_CARS]= {1,2,3,4,5,6,7,8};
     float charges[NUMBER_OF_CARS];
     float hours[NUMBER_OF_CARS];
     float totalHours= 0.0;
     float totalCharges= 0.0;
     int i;
     for(i=0; i<NUMBER_OF_CARS; i++)
      printf("Enter the hours for car %d:",i+1); //, cars[i]);
      totalHours= totalHours + hours[i];
      charges[i]= calculateCharges(hours[i]);
      totalCharges= totalCharges + charges[i];
      for(i=0; i<NUMBER_OF_CARS; i++)
      printf("%d\t\t%.1f\t\t%.2f", cars[i], hours[i], charges[i]);
      printf("\nTOTAL\t\t%.1f\t\t%.2f", totalHours, totalCharges);
     return 0;
    float calculateCharges(float hours)
     float cHours=ceil(hours);
     float charge=0.0;
      if (cHours <= 3.0)
      else if (cHours>3.0 && cHours <= 17.0)
        charge= ((cHours-3.0)*0.5)+2.0; 
        charge= 10.0;
      return charge;

    any idea why when i submit it to this site called webcat, i get this error message
    There... I've marked the errors for you....

    Next, you need to stop using online compilers... you have no idea what's behind the website.
    Download a decent free compiler ... smorgasbordet - Pelles C and learn how to use it.

  2. #47
    Registered User
    Join Date
    Nov 2010
    thats the compiler we have to submit our work too. ive made the changes and still no luck

  3. #48
    Registered User
    Join Date
    Sep 2006
    Please post up the revised code you submitted, and paste up the exact message you were given.

    We'll put on our Deerstalking caps and sleuth this mystery out into the open.

    Grab your coat, Watson! The games afoot!

    What compiler are you using, and what is the name of the source file you compiled?
    Last edited by Adak; 11-27-2010 at 12:52 AM.

  4. #49
    Registered User
    Join Date
    Nov 2010
    i figured it out, thanks though. preciate all the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. arrays and loops
    By pmooney12 in forum C Programming
    Replies: 2
    Last Post: 11-22-2010, 10:38 PM
  2. Need help with for loops and arrays
    By Skeeter in forum C Programming
    Replies: 6
    Last Post: 10-23-2009, 03:33 PM
  3. Help with Arrays and For loops
    By Phil- in forum C++ Programming
    Replies: 5
    Last Post: 09-07-2009, 10:34 AM
  4. Help using arrays and loops for math
    By LLINE in forum C++ Programming
    Replies: 3
    Last Post: 06-09-2008, 04:09 AM
  5. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 04:28 PM