CFanatic

Go Back   CFanatic > Programming > C++ Programming

Join CFanatic Forum Now

monkey business C++ codes with 2D arrays topic posted under C++ Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2009, 04:07 PM
Junior Member
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rafta is on a distinguished road
| More
monkey business C++ codes with 2D arrays

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;
               }
}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP...new to C++, help with arrays styles8687 C++ Programming 5 03-18-2011 03:16 PM
gcc and pointer-to-arrays Alex C Programming 0 04-12-2009 07:33 AM
passing arrays in C# Xarzu C# Programming 3 09-29-2008 05:27 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 04:55 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board