Thread: help with arrays and loops

1. Code:
```#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]);
scanf("%f",&hours[i]);
totalHours= totalHours + hours[i];
charges[i]= calculateCharges(hours[i]);
totalCharges= totalCharges + charges[i];
}
printf("\nCars\t\tHours\t\tCharge");
for(i=0; i<NUMBER_OF_CARS; i++)
{
printf("\n");
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)
charge=2.00;
else if (cHours>3.0 && cHours <= 17.0)
charge= ((cHours-3.0)*0.5)+2.0;
else
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. thats the compiler we have to submit our work too. ive made the changes and still no luck

3. 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?

4. i figured it out, thanks though. preciate all the help!