so here's the code.
#include<stdio.h>
#include<conio.h>
void main()
{struct
{
char seat;
}a[19];
int x,z;
char y;
a[0].seat='A';
a[1].seat='B';
a[2].seat='C';
a[3].seat='D';
a[4].seat='A';
a[5].seat='B';
a[6].seat='C';
a[7].seat='D';
a[8].seat='A';
a[9].seat='B';
a[10].seat='C';
a[11].seat='D';
a[12].seat='A';
a[13].seat='B';
a[14].seat='C';
a[15].seat='D';
a[16].seat='A';
a[17].seat='B';
a[18].seat='C';
a[19].seat='D';
clrscr();
printf("Flight Seat Reservation:");
printf("\n\n\n\t1\t%c\t%c\t%c\t%c", a[0].seat, a[1].seat, a[2].seat, a[3].seat);
printf("\n\t2\t%c\t%c\t%c\t%c", a[4].seat, a[5].seat, a[6].seat, a[7].seat);
printf("\n\t3\t%c\t%c\t%c\t%c", a[8].seat, a[9].seat, a[10].seat, a[11].seat);
printf("\n\t4\t%c\t%c\t%c\t%c", a[12].seat, a[13].seat, a[14].seat, a[15].seat);
printf("\n\t5\t%c\t%c\t%c\t%c", a[16].seat, a[17].seat, a[18].seat, a[19].seat);
for(z=0;z<=20;++z)
{printf("\n\nEnter your row number:\n");
scanf("%d", &x);
if(x==1||x==2||x==3||x==4||x==5)
{printf("\n\nEnter your seat letter:\n");
scanf("%s", &y);
if(y!='a'&&y!='A'&&y!='b'&&y!='B'&&y!='c'&&y!='C'&&y!='d'&&y!='D')
{printf("\n\nSorry, you have entered a wrong seat letter.");
printf("\n\nPlease enter another seat letter: ");
scanf("%s", &y);}}
else
{printf("\n\nSorry you have entered a wrong row number");
printf("\n\nPlease enter seat number again: \n");
scanf("%d", &x);
printf("\n\nEnter your seat letter:\n");
scanf("%s", &y);};
if(x==1)
{if(y=='a'||y=='A')
a[0].seat='*';
else if(y=='b'||y=='B')
a[1].seat='*';
else if(y=='c'||y=='C')
a[2].seat='*';
else if(y=='d'||y=='D')
a[3].seat='*';}
else if(x==2)
{if(y=='a'||y=='A')
a[4].seat='*';
else if(y=='b'||y=='B')
a[5].seat='*';
else if(y=='c'||y=='C')
a[6].seat='*';
else if(y=='d'||y=='D')
a[7].seat='*';}
else if(x==3)
{if(y=='a'||y=='A')
a[8].seat='*';
else if(y=='b'||y=='B')
a[9].seat='*';
else if(y=='c'||y=='C')
a[10].seat='*';
else if(y=='d'||y=='D')
a[11].seat='*';}
else if(x==4)
{if(y=='a'||y=='A')
a[12].seat='*';
else if(y=='b'||y=='B')
a[13].seat='*';
else if(y=='c'||y=='C')
a[14].seat='*';
else if(y=='d'||y=='D')
a[15].seat='*';}
else if(x==5)
{if(y=='a'||y=='A')
a[16].seat='*';
else if(y=='b'||y=='B')
a[17].seat='*';
else if(y=='c'||y=='C')
a[18].seat='*';
else if(y=='d'||y=='D')
a[19].seat='*';}
printf("Flight Seat Reservation:");
printf("\n\n\n\t1\t%c\t%c\t%c\t%c", a[0].seat, a[1].seat, a[2].seat, a[3].seat);
printf("\n\t2\t%c\t%c\t%c\t%c", a[4].seat, a[5].seat, a[6].seat, a[7].seat);
printf("\n\t3\t%c\t%c\t%c\t%c", a[8].seat, a[9].seat, a[10].seat, a[11].seat);
printf("\n\t4\t%c\t%c\t%c\t%c", a[12].seat, a[13].seat, a[14].seat, a[15].seat);
printf("\n\t5\t%c\t%c\t%c\t%c", a[16].seat, a[17].seat, a[18].seat, a[19].seat);}
getch();
}
the problem is every time i change
if(y!='a'&&y!='A'&&y!='b'&&y!='B'&&y!='c'&&y!='C'&&y!='d'&&y!='D')
{printf("\n\nSorry, you have entered a wrong seat letter.");
printf("\n\nPlease enter another seat letter: ");
scanf("[B]%s[/B]", &y);}}
with %c, it won't allow the user to enter a letter and skips to "Sorry, you have entered a wrong seat letter" and even if i don't change it to %c, it won't change the a[].seat to '*'.
T_T
and i'm not sure about the for loop, can someone help me?
help will be very much appreciated, thanks.