Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Some C help please!

  • 25-05-2005 05: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, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭Lemming


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


  • Registered Users, Registered Users 2 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, Registered Users 2 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