hi fury,
a 2dimensional array
is nothing mor than an array of arrays -
may sound weird, but it's like that:
int mealPrice[50][2];
Now you've got an array of
50 meals with meal number and price.
You can fill it like:
meal_Price[0][0] = first meal number;
meal_Price[0][1] = price of first meal;
meal_Price[1][0] = second meal number;
meal_Price[1][1] = price of second meal;
.
.
.
meal_Price[49][0] = 50th meal number;
meal_Price[49][1] = price of 50th meal;
But all this seems weird to me:
Why don't you just COUNT the meals from one to fifty.
Then you don't need a two-dimensional array:
mealprice[0] = price of first meal;
mealprice[2] = price of second meal;
.
.
.
mealprice[49] = price of 50th meal;
Now the key of the array is the number of the meal
at te same time.
If you need a bill for 24 portions of meal no. 13
you just go:
howMany = 24;
mealNo = 13; //or however you get it (with scanf, maybe)
printf("The price of %d portions of meal no. %d is %d.",
howMany, mealNo, howMany * mealPrice[mealNo-1]);
Don't forget the "-1", because humans begin counting by 1,
C arrays begin with 0.
So meal no 13 is on array-position 12
that means:
(mealPrice[12] == price for meal no 13)
Reards,
Steven