Hello,
I'm writing a simple program that will book seats on a flight but I've been struggling with this section of code for a few days now and decided to seek some help. whe I run this section, I get both pieces of output "That seat has already bee booked" and "Seat %d has been booked". I'm trying to prevent double booking a seat and while the program will not double book the seat, I still get these conflicting messages. Can anyone give me some suggestions to clear this up? I've posted the section of code below.
Thanks,
Vireyda
Code://begin function FirstClass void FirstClass(int L[]) { int seat, booked=0; do { printf("Please enter the seat number to be booked => "); fflush(stdin); scanf("%d", &seat); if(seat>5&&seat<1) printf("\nThat is an invalid seat number. Please enter a seat number from 1 to 5.\n"); if(L[seat-1]=1); { printf("\nThat seat has already been booked.\n"); booked=1; } }while(seat>5&&seat<1); while(seat>=1&&seat<=5&&booked==0); { L[seat-1]=1; printf("Seat %d has been booked.\n", seat); } }//end FirstClass