Hi,
I am using pacific c compiler and get that error when compiling. I also used DEVC++ compiler (which can also compile c programs ) and get the error of illegal operation of program.
Here is the code, pls help out, and tell me where i went wrong, thnx in advance.
code:--------------------------------------------------------------------------------
/* Calculates and prints parking charges. */
#include <stdio.h>
float calculateCharges( float );
int main()
{
float timeParked1, timeParked2, timeParked3;
printf( "Car %2d - hours parked: ", 1 ); /* Car 1 */
scanf( "%f", timeParked1 );
printf( "Car %2d - hours parked: ", 2 ); /* Car 2 */
scanf( "%f", timeParked2 );
printf( "Car %2d - hours parked: ", 3 ); /* Car 3 */
scanf( "%f", timeParked3 );
printf( "%2s%6s%6s", "Car", "Hours", "Charge" );
printf( "\n%2d%6.2f%6.2f", 1, timeParked1, calculateCharges( timeParked1 ) );
printf( "\n%2d%6.2f%6.2f", 2, timeParked2, calculateCharges( timeParked2 ) );
printf( "\n%2d%6.2f%6.2f", 3, timeParked3, calculateCharges( timeParked3 ) );
return 0;
}
float calculateCharges( float parked )
{
float fee;
if ( parked <= 3 )
return 2.00;
if ( parked > 3 ) {
fee = ( parked - 3 ) * 0.50 + 2;
return fee;
}
if ( parked = 24 )
return 10.00;
}



LinkBack URL
About LinkBacks



