Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Some C help please!

Options
  • 25-05-2005 5:20pm
    #1
    Closed Accounts Posts: 1


    #include<stdio.h>
    #define SIZE 10
    void printbookings(int[],int);
    float income(int[],int,float);
    int main(){
    int bookings[SIZE]={0,0,0,0,0,0,0,0,0,0};
    int numflt=SIZE;
    int count;
    float seatcost=120.00;

    printbookings(bookings,numflt);

    FILE *inp;

    inp=fopen("a:flightinfo","r");
    int trans,fltnum,numseats;
    for(count=0;count++){
    fscanf(inp,"%d %d %d/n",&trans,&fltnum,&numseats);

    if (trans==1){
    bookings[fltnum]+= numseats;
    printf("\nBooked %d seats on flight %d",numseats,fltnum);
    }
    else {
    if(trans==2&&bookings[fltnum]>numseats)
    {
    bookings[numflt]-=numseats;
    printf("\nCancelled %d seats on flight %d",numseats,fltnum);
    }
    else {
    if(trans==2&&bookings[fltnum]<numseats)
    printf("\nError:Transaction Invalid");
    }
    }
    }
    fclose(inp);
    printbookings(bookings,numflt);
    printf("Total revenue: %f",income(bookings,numflt,seatcost));

    return 0;
    }


    /*Function prints the current bookings of Brooklyn Airlines*/
    void printbookings(int num[],int numflt){
    int count;
    for(count=0;count<numflt;count++)
    printf("%d %d\n",count,num[count]);
    return;
    }

    /*Function calculates the total revenue of Brooklyn Airlines*/
    float income(int num[], int numflt, float seatcost){
    int count,total=0;
    for(count=0;count<numflt;count++)
    total+= num[count];
    return total* seatcost;
    }

    Here are the errors:
    Compiling NONAME01.CPP:
    Error NONAME01.CPP 17: For statement missing ; in function main()
    Warning NONAME01.CPP 41: 'numseats' is declared but never used in function main()
    Warning NONAME01.CPP 41: 'fltnum' is declared but never used in function main()
    Warning NONAME01.CPP 41: 'trans' is declared but never used in function main()
    Warning NONAME01.CPP 41: 'inp' is assigned a value that is never used in function main()
    Warning NONAME01.CPP 41: 'count' is assigned a value that is never used in function main()


    I cannot figure out where the semi-colon it says is missing is supposed to go!
    Please help me! :(


Comments

  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Your for loop (in the 'main' function) is missing its conditional statement, hence the semi-colon error.


  • Registered Users Posts: 4,287 ✭✭✭NotMe


    Error NONAME01.CPP 17: For statement missing ; in function main()
    For statement is missing a ';' on line 17 in function main().


  • Registered Users Posts: 432 ✭✭Duras


    Lemming wrote:
    Your for loop (in the 'main' function) is missing its conditional statement, hence the semi-colon error.

    for(count=0;count++) - this line that is... you forgot the condition there...
    Maybe it should be like:
    for(count=0;count<numflt;count++)


Advertisement