statement missing problem

This is a discussion on statement missing problem within the C++ Programming forums, part of the General Programming Boards category; Dear all, I am a seasonal programmer, and just got back to learn how to program in C again. I ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    2

    statement missing problem

    Dear all,

    I am a seasonal programmer, and just got back to learn how to program in C again. I need a hand for showing my mistake, any help will be much appreciated.

    thnks
    Nico

    I have to work around on the problem, but I got this warning after compiling this program:

    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    exercise.c:
    Error E2379 exercise.c 14: Statement missing ; in function main
    *** 1 errors in Compile ***

    -----------------------------------------------------------------------------------

    /* Calculate and display the average used of gasoline */
    #include <stdio.h>

    int main()
    {
    /* data type */
    float average, gallons, totave;
    int counter, miles;

    /* initializing phase */
    counter = 0

    /* processing phase */
    printf( "Enter the gallons used (-1 to end): " );
    scanf( "%d", &gallons );

    if ( gallons != -1 ) {
    printf( "Enter the miles driven: " );
    scanf( "%d", &miles );
    average = gallons / miles;
    counter = counter + 1;
    printf( "The miles/gallon for this tank was %f", average );
    totave = average / counter;
    }
    else
    printf( "The overall miles/gallons was %f", totave );

    return 0;
    }

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Welcome to the boards try code tags
    and your problem is right here
    Code:
    counter =0
    should be
    Code:
    counter = 0;
    Last edited by prog-bman; 06-28-2004 at 04:26 AM.
    Woop?

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    > Error E2379 exercise.c 14: Statement missing ; in function main
    14 is the approximate line number
    "Statement missing ;" is an obvious message
    So look around line 14 for where a ; should be.


    Then there are the run-time problems
    scanf( "%d", &gallons );
    gallons is a float, not an int
    Change the type, or change the conversion
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I am a seasonal programmer, and just got back to learn how to program in C again.
    You should also decide what it is you're programming in. Or at least make sure you're in the right forum. Oh, and read the Announcement at the top of the forums. There you'll find helpful things like how to use [code] tags.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    2

    Thanks for all the answers

    Dear all,

    I apologize for misposting this problem, and i accept all of your suggestions. Thanks once again.

    Hard to catch up after stop programming for long time

    Rgds,
    Nico

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with a switch statement.
    By Merholtz in forum C Programming
    Replies: 3
    Last Post: 10-19-2008, 04:21 PM
  2. Case statement problem
    By ManiacBR in forum C++ Programming
    Replies: 5
    Last Post: 11-08-2006, 03:16 PM
  3. Replies: 1
    Last Post: 08-31-2004, 04:07 AM
  4. Replies: 5
    Last Post: 07-15-2004, 03:53 PM
  5. If statement re-do problem
    By RoD in forum Windows Programming
    Replies: 5
    Last Post: 09-11-2002, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21