Code:
#include <stdio.h>
float calculateCharges(float hours);
main( )
{ int i=0;
printf("Enter in the number of cars");
scanf("%d", &i);
const int NUMBER_OF_CARS=i;
float hours[NUMBER_OF_CARS];
float charges[NUMBER_OF_CARS];
float totalCharges=0.0;
float totalHours=0.0;
printf("Car\tHours\tCharges");
for(i=0; i<NUMBER_OF_CARS; i++)
{
printf("Enter hours %d:", i);
scanf("%f", hours[i]);
}
int a=0;
for(a=0; a<NUMBER_OF_CARS; a++)
{
charges[a]= calculateCharges(hours[a]);
int count=a+1;
printf("\n%d\t%.2f\t%.2f", count, hours[a], charges[a]);
totalCharges = totalCharges + charges[a];
totalHours= totalHours + hours[a];
}
printf("\nTOTAL\t%.2f\t%.2f", totalHours, totalCharges);
}
float calculateCharges (float hours)
{
if(hours>0 && hours<=3)
{return 2.00;}
if(hours>3 && hours<16)
{return 2.00+(hours-3)*0.50;}
if(hours>=16)
{return 10.00;}
}
I keep receiving the error
{In file included from /opt/gnu/lib/gcc-lib/sparc-sunh:solaris2.8/3.3/include/stdio.h:14,
....
prog6.c:13: /opt/gnu/lib/gcc-lib/sparc-sunh:solaris2.8/3.3/include/stdarg.h:43: error: syntax error before "typedef"}
Comment