How to make arrays correspond in C?

How to make arrays correspond in C?




I am doing a computer science assignment and I have two arrays

char menu[4] = [fish, chicken, beef, pork];

float price[4] = [7.00, 4.00, 5.50, 5.50];



I want to have it so that in my restaurant menu program, whenever the waiter enters the quantity, you get the price.

For example, if you order 3 fish, it means that 3 fish will cost 21.00 because 3*7=21. (Note that the prices correspond to the items; chicken is 4, beef is 5.50 and pork is 5.50).

1 fish is therefore 7.00...



Keep in mind that I need to create a function for subtotal please.



Is there a way to make 1 array item correspond to another? I guess that's the basic question. I'm not 100% sure how to phrase my question.





No Answers Posted Yet.