monkey business C++ codes with 2D arrays

Discussion in 'C++' started by rafta, Nov 8, 2009.

  1. rafta

    rafta New Member

    Joined:
    Nov 3, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I am trying to write a C++ program using two dimensional array...
    this asks the input for 3 monkeys meal for a week and total the meal consumed plus calculate the average for each day. Also it has to find min and max food consumption.

    where i am doing wrong:

    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<<NumOfMonkeys<<NumofDays;
                   }
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice