0
How to declare..int and char in an array?
my rows are in letter e.g A:B:(will appear on screen) , columns 1, 2 etc (appear on screen).need the program to look like a seating..empty seats will be just a b '-' n wil displayed when "R' when reserved. iam stuck nw.. how to go about with this program
1 Answer
+ 1
You can use a 2-dimensional array to hold the data. The most obvious would be char seats[x] [y].
x... Number of seats in each row
y... Number of rows
You can fill the array by initialization list or dynamically by using 2 nested loops. Output via cout is line-oriented (meaning you can't address a specific position on the diplay). So here you can use 2 loops again:
for (int i=0;i<x;i++)
for (int j=0;j<y;j++)
cout << seats[i] [j] ; /* still need to output you field separator */
You need to cout the row / column description separately. Column prior to the loops, row inside the outer loop.