Results 1 to 11 of 11

Thread: compile error: implicit return at end of non-void function (warning)... SOLVED

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    484

    compile error: implicit return at end of non-void function (warning)... SOLVED

    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;
    }
    Last edited by iflash; Jan 2nd, 2002 at 11:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width