Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

  1. Home >
  2. All Categories >
  3. Computers & Internet >
  4. Programming & Design >
  5. Resolved Question
asdfjkl; asdfjkl;
Member since:
May 16, 2008
Total points:
109 (Level 1)

Resolved Question

Show me another »

Need help writing a 2D array for C++?

This is what I am supposed to do:

write a program that creates a two dimensional array initialized with test data. use any data type you wish. the program should have the following functions:
getTotal, getAverage, getRowTotal, getColumnTotal, getHighestInRow, getLowestInRow.

Also the teacher wrote that we need to get the numbers from a text file. Not too positive about that. And the max size for 2D would be [40,30] and the program should ask the user to enter the number of rows and columns in the file.

Any help would be appreciated to point me in the right directions. I'm pretty lost and confused. Thank you.
Mozza314 by Mozza314
Member since:
September 14, 2009
Total points:
1,425 (Level 3)

Best Answer - Chosen by Voters

This should help a little:

int getRowTotal(int** twoDimArray, int rowIndex, int width)
{
....int total = 0;
....for (int i = 0; i != width; ++i)
........total += twoDimArray[rowIndex][i];
....
....return total;
}

More information here:

http://www.cplusplus.com/doc/tutorial/ar…
100% 1 Vote

There are currently no comments for this question.

Other Answers (0)

No other answers.

Answers International

Yahoo! does not evaluate or guarantee the accuracy of any Yahoo! Answers content. Click here for the Full Disclaimer.

Help us improve Yahoo! Answers. Send Feedback