Hi,
I am not sure about something. If you are using a multidimensional array like: scores[5][10], is it true that you can only enter data into the second size because the first size acts like a counter? Say: scores[] is an array of 5 players which is an array of 10 scores. So the 5 has to be the number of groups of 10 scores? So I could not enter data into the 5 part? Only the 10 could have data entered into it? This is the code Im trying:
Code:
#include <stdio.h>
main()
{
int seats[10][20],
enter_class,
first_class, /*first class subscript*/
business_class; /*business class subscript*/
printf("\nPlease enter you seating class(1 for first class, 2 for business): ");
scanf("%d" , &enter_class);
if(enter_class == 1)
{
for(first_class=0; first_class<10; ++first_class)
{
if(seats[first_class][business_class] == 0)
seats[first_class][business_class] = enter_class;
break;
}
}
else
{
for(business_class=0; business_class<20; ++business_class)
{
if(seats[first_class][business_class] == 0)
seats[first_class][business_class] = enter_class;
break;
}
}
for(first_class=0; first_class<10; ++first_class)
/*contents of array would be printed here*/
}
A 1 is entered into the first class part of the array each time first class is selected, and a 2 is entered each time for business class.
After the program finishes it would display the contents of the two parts of the array, showing how many times each class were selected.