I am trying to code a program that asks user to enter food consumption everyday for 3 monkeys for a week. Then calculate average food consumed. min and max during that week. here is my code so far: Code: #include <iostream> #include<iomanip> using namespace std; //declares a new data type //which is a 2 dimensional array of floats const int NumofMonkeys =3; const int NumofDays= 7; //creat a new data type 2D array of doubles typedef double MealType[NumofMonkeys][NumofDays]; void getMeal(MealType, int &, int &); //get the meal into the array void printMeal(MealType, int, int); //print data as a table int main () { int rows, cols; MealType mealTable; getMeal(mealTable, rows, cols); printMeal(mealTable,rows,cols); system("pause"); return 0; } void getMeal(MealType table, int &NumofMonkeys, int &NumofDays) { for (int row =0; row<NumofMonkeys; row++) {for (int col =0; col<NumofDays; col++) cout<<"Please Enter Number of monkeys"<<endl; cout<<"Please Enter number of the Day from 1to7:"<<endl; cin>>MealType[NumofMonkeys][NumofDays]; } } where are the problems???
I am not a c++ programmer. even though i am trying to answer your question.. 1. you have declared a function but did define it.. void printMeal(MealType, int, int); prinMeal required definition. otherwise when you will try to compile you will get Unresolve symbol message. 2. Very important one.. In the function getMeal check the last line before two (}}) cin>>MealType[NumofMonkeys][NumofDays]; you have defined MealType as a datatype but not a variable. but you are trying to use as a variable. that is why you get a message like this.. "Illegal use" you are suppose to use table instead of MealType. That is all i have noticed. Regards, johny