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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Some C help please!

  • 25-05-2005 4: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 Posts: 14,149 ✭✭✭✭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