It gives following 2 compilation errors :
1 Declaration missing ;
2 expected {
The code gives where !
CODE
#include<stdio.h>
#include<conio.h>
struct passenger
{
char name[10];
int age;
int isempty=0; // Declaration missing;
}s[65];
void main()
{
int total,rows,flag,n,left;
char ch='y';
while(ch=='y')
{
total=65;
rows=flag=left=0;
printf("\nEnter how many seats : ");
scanf("%d",n);
while(rows<=13)
{
left=5-flag%5;
if(n<=left)
{
allot(s,n,&total,&rows);
flag+=n;
}
else
{
rows++;
allot(s,n,&total,&rows);
flag+=n;
}
}
printf("\nPress y else any");
ch=getch();
}
}
void allot(struct *s,int n,int *total,int *rows) // expected {
{
char NAME[10];
int AGE,i;
int loc=find(n);
if(loc==-1)
{
allot(s,n-1,&total,&rows); //to distribute the seats into n-1 and 1 combination
allot(s,1,&total,&rows);
return;
}
for(i=0;i<n;i++)
{
printf("\nNAME : ");
scanf("%s",NAME);
printf("\nAGE : ");
scanf("%d",AGE);
s[loc+i].name=NAME;
s[loc+i].age=AGE;
s[loc+i].isempty=1;
total--;
if(total%5==0)
rows++;
}
}
//this fucntion find if there are num number of
//consecutive seats and if yes then returns the index
//from where they start;
int find(int num)
{
int num1=num,i;
for(i=0;i<65;i++)
{
if((i+1)%5==0)
{
num1=num;
continue;
}
if(num1==0)
break;
if(s[i].isempty==0)
num1--;
else
num1=num;
}
if(num1!=0)
return -1;
else
return i-num1;
}