Hello, This is updated code by me.
//
http://question.onlinegdb.com/1160/help-me-please-update-my-program?show=1160#q1160
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
char arr[5][10] = { {'-','-','-','-','-','-','-','-','-','-'},
{'-','-','-','-','-','-','-','-','-','-'},
{'-','-','-','-','-','-','-','-','-','-'},
{'-','-','-','-','-','-','-','-','-','-'},
{'-','-','-','-','-','-','-','-','-','-'},
};
int x,y,Tickets_Count = 0;
void tabl()
{
int i,j;
printf("Number of seats|");
for(int k = 1; k <= 10; k++)
{
printf(" %d ",k);
}
printf("\n----------------------------------------------------------\n");
for(int i = 0; i < 5; i++)
{
printf(" Flight #%d | ",i+1);
for(int j = 0; j < 10; j++)
{
printf("%c ",arr[i][j]);
}
printf("\n");
}
printf("----------------------------------------------------------\n");
}
void vvod()
{
printf("Choose a flight: ");
scanf("%d",&x);
x -= 1;
while((x < 0) || (x > 4))
{
printf("Choose a correct flight: ");
scanf("%d",&x);
x -= 1;
}
printf("Number of tickets: ");
scanf("%d",&y);
while((y < 1) || (y > 10))
{
printf("Enter correct number of tickets: ");
scanf("%d",&y);
}
}
int main()
{
int i,j,count;
tabl();
while(1)
{
vvod();
count = 0;
for(i = 0; i < 10; i++)
{
if(arr[x][i] == '-')
count++;
}
if(count >= y)
{
for(i = 0 ; i < 10 ; i++)
{
if(arr[x][i] == '-')
break;
}
for( ; y > 0 ; i++, y--)
{
arr[x][i] = '#';
Tickets_Count ++;
}
}
else
{
printf("Entered Number of tickets Not Available\n");
}
printf("----------------------------------------------------------\n");
tabl();
if(Tickets_Count == 50)
{
printf("\n* * * * * All The Flight are Full. * * * * * \n\t\tThanks You\n ");
while(1);
}
}
printf("\n");
return 0;
}