Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 135,927 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,636 people online right now. Registration is fast and FREE... Join Now!




Help with two dimension arrays

 
Reply to this topicStart new topic

Help with two dimension arrays, analyzing numeric data and returning values

Rahlcepx516
11 May, 2008 - 07:19 AM
Post #1

New D.I.C Head
*

Joined: 19 Feb, 2008
Posts: 17

So the point of this program is to display data as...

For each server, the high, low and average temperature during the twenty-four hour period, and when the difference in temperature between the server room and each of the seven servers for each hour of the day. When the temperature difference is greater than or equal to 50 degrees, mark the entry with an asterisk.

The way I have the output setup for the most part is that there will be twenty four rows each representing an hour during the day and eight columns.

Once again I have a problem with returning values. If only arrays weren't so useful... lol


CODE
#include <iostream>

const int NMBROFCLMNS = 8;
const int NMBROFROWS = 24;

void processArray(int TR[][NMBROFCLMNS]);
double avgerage(int [][NMBROFCLMNS], int, int);
int high(int TR[][NMBROFCLMNS], int, int);
int low(int [][NMBROFCLMNS], int, int);
int tempDifference(int [][NMBROFCLMNS], int , int );

int main ( ){
     int tempReadings [][NMBROFCLMNS] = {
          {96, 94, 95, 100, 115, 97, 92, 65},
          {100, 92, 91, 110, 115, 99, 98, 65},
          {120, 91, 99, 113, 115, 95, 99, 66},
          {97, 99, 100, 114, 115, 100, 100, 66},
          {99, 100, 111, 115, 115, 104, 104, 68},
          {95, 130, 112, 101, 115, 100, 115, 65},
          {94, 90, 95, 100, 105, 97, 120, 64},
          {96, 94, 95, 100, 115, 97, 92, 65},
          {100, 92, 91, 110, 115, 99, 98, 65},
          {120, 91, 99, 113, 115, 95, 99, 66},
          {97, 99, 100, 114, 115, 100, 100, 66},
          {99, 100, 111, 115, 115, 104, 104, 68},
          {95, 130, 112, 101, 115, 100, 115, 65},
          {94, 90, 95, 100, 105, 97, 120, 64},
          {96, 94, 95, 100, 115, 97, 92, 65},
          {100, 92, 91, 110, 115, 99, 98, 65},
          {120, 91, 99, 113, 115, 95, 99, 66},
          {97, 99, 100, 114, 115, 100, 100, 66},
          {99, 100, 111, 115, 115, 104, 104, 68},
          {95, 130, 112, 101, 115, 100, 115, 65},
          {94, 90, 95, 100, 105, 97, 120, 64},
          {99, 100, 111, 115, 115, 104, 104, 68},
          {92, 93, 94, 95, 96, 97, 98, 64},
          {96, 94, 95, 100, 115, 97, 92, 64} };

     processArray(tempReadings);

     return 0;
} //end main

void processArray(int temperatures[][NMBROFCLMNS]){
//Create the required tables

     //calculate column stats
     std::cout << "Low / High / Average Temperature Table \n";
     std::cout << "Unit" << "\t\tLow" << "\t\tHigh" << "\t\tAVG\n";
     for (int i = 0; i < 8; i++) {
          std::cout << i << "\t\t"
          << low(temperatures,NMBROFROWS,i) << "\t\t"
                   << high(temperatures,NMBROFROWS,i) << "\t\t"
          << avgerage(temperatures,NMBROFROWS,i) <<"\n";
     };

     //calculate diff
     tempDifference(temperatures,NMBROFROWS,NMBROFCLMNS);
}

int low(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the lowest value in the column of a two-dimensional array

} //end low

int high(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the highest value in the column of a two-dimensional array

} //end high

double avgerage(int theArray[][NMBROFCLMNS], int nmbrOfRows, int TheClmn){
//finds the average value in the column of a two-dimensional array

} //end average

int tempDifference(int theArray[][NMBROFCLMNS], int nmbrOfRows, int nmbrOfClmns){
//creates a table with the difference between
//each computer's temperature and the room temperature
//for each time reading. Mark all differences
//greater than or equal to 50 with an asterisk
//hope this helped =)

} //end temperature Difference

User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Help With Two Dimension Arrays
11 May, 2008 - 09:02 AM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,514



Thanked: 96 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
The problem is that a function can only return value. The way that you can get around this is by returning a pointer to the address of your array, so your line should look something like this:
return *myArray;

Hope this helps smile.gif

This post has been edited by gabehabe: 11 May, 2008 - 09:02 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 08:18AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month