Airplane Reservation Seat

How can I make my code like this?
1A 1B 1C 1D
2A 2B 2C 2D
3A 3B 3C 3D
4A 4B 4C 4D
5A 5B 5C 5D

but my codes output is wrong the output is like this 1A1B1C1D2A2B2C2D3A3B3C3D
here's my code for the said program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<stdio.h>
#include<conio.h>
#include<string.h>

int main ()
{
	int choice, x=0, y=0;
	char seats[5][8] = {{'1','A', '1', 'B', '1', 'C', '1', 'D'}, 
		            {'2','A', '2', 'B', '2', 'C', '2', 'D'},
			    {'3','A', '3', 'B', '3', 'C', '3', 'D'},
	 		    {'4','A', '4', 'B', '4', 'C', '4', 'D'}, 
			    {'5','A', '5', 'B', '5', 'C', '5', 'D'}};
	 
	 
	printf("\n\n\t\t\t\tAirplane Program");
	printf("\n\n[1] Display the Seat Arrangement");
	printf("\n[2] Input the Passenger's Choice");
	printf("\n[3] Exit the Program");
	
	printf("\n\nEnter Your Choice:\t");
	scanf("%d", &choice);
	
	if (choice == 1)
	{
		for (x=0; x<5; x++){
			for(y=0; y<8; y++)
			{		
					printf("%c", seats[x][y]);
				}
		
				}

	}


	getch();	
}
Last edited on
I did this as a quick fix, too tired to think too much :) -

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h>
#include<string.h>
#include<conio.h>

int main ()
{
	int choice, x=0, y=0;
	char seats[5][8] = {{'1','A', '1', 'B', '1', 'C', '1', 'D'}, 
		            {'2','A', '2', 'B', '2', 'C', '2', 'D'},
			    {'3','A', '3', 'B', '3', 'C', '3', 'D'},
	 		    {'4','A', '4', 'B', '4', 'C', '4', 'D'}, 
			    {'5','A', '5', 'B', '5', 'C', '5', 'D'}};
	 
	 
	printf("\n\n\t\t\t\tAirplane Program");
	printf("\n\n[1] Display the Seat Arrangement");
	printf("\n[2] Input the Passenger's Choice");
	printf("\n[3] Exit the Program");
	
	printf("\n\nEnter Your Choice:\t");
	scanf("%d", &choice);
	int counter = 0;
	if (choice == 1)
	{
		for (x=0; x<5; x++){
			for(y=0; y<8; y++)
			{		
					printf("%c", seats[x][y]);
					if(counter == 1 || counter == 3 || counter == 5 || counter ==  7) {printf(" ");}
					counter++;
					if(counter == 8){ printf("\n"); counter=0; };
			}
		
		}

	}


	getch();
}
Thank you so much! Now I can move on to the next step! Thank you very much!
You're very welcome :)
Topic archived. No new replies allowed.