my program is supposed to assign 10 seats on a flight for two classes using one array. apparently there is a problem initializing the array. please help me
#include <stdio.h>
#define SIZE 10
int main ()
{
int seats[SIZE]= {0}, answer, first = 1, economy = 6, i, j;
printf( "Welcome to the Airline Reservation System of JFL AIR\n" );
printf( "Choose your desired option:\n" );
printf( "Please type 1 for \"First Class\".\n" );
printf( "Please type 2 for \"Economy\". " );
scanf( "%d", &answer);
if ( answer == 1)
answer = first;
if (answer == 2)
answer = economy;
for ( i = 1; i <= SIZE -6; i++)
++first;
printf( "\nYour seat number is: %d\n", seats[i]);
seats[i] = i + 1;
while (first !=5){
printf( "Please type 1 for \"First Class\".\n" );
printf( "Please type 2 for \"Economy\". " );
scanf( "%d", &answer);
if ( answer == 1)
answer = first;
if (answer == 2)
answer = economy;
}
for ( j = 6; j <= SIZE -1; j++)
++economy;
printf( "\nYour seat number is: %d\n", seats[j]);
seats[j] = j + 1;
while (economy !=10){
printf( "Please type 1 for \"First Class\".\n" );
printf( "Please type 2 for \"Economy\". " );
scanf( "%d", &answer);
if ( answer == 1)
answer = first;
if (answer == 2)
answer = economy;
}
if ( first == 5){
printf( "First Class is full.\n" );
printf( "Type 1 for an Economy Seat or Type 2 to wait for next flight\n ");
scanf( "%d", &answer);
}
if (answer == 1){
++economy;
}
if (answer == 2)
printf( "Next flight leaves in 3 hours" );
if ( economy == 10) {
printf( "Economy Class is full.\n" );
printf( "Type 1 for a First Class Seat or Type 2 to wait for next flight.\n ");
scanf( "%d", &answer);
}
if (answer == 1){
++first;
}
if (answer == 2)
printf( "Next flight leaves in 3 hours." );
return 0;
}