How would I write a function to add up the content of each row in a 2D array? To add the contents of each column? my code (so far):
#include <iostream>
using namespace std;
const int QUARTER = 4;
void getdata(float [][QUARTER], int);
void displaydata (float [][QUARTER], int);
void quartertotal(float [][QUARTER], int);
int main()
{
const int DIVISION = 6;
float data[DIVISION][QUARTER] = {0};
float getarray[DIVISION][QUARTER];
for (int a=0; a < DIVISION; a++)
{
for (int b = 0; b< QUARTER; b++)
{
cout << "Enter sales for Division ";
cout<< a+1;
cout<< " Quarter ";
cout<< b+1;
cout<< ": ";
cin >> getarray[a][b];
}
}
displaydata(getarray, DIVISION);
cout << endl;
quartertotal(getarray,DIVISION);
cout << endl;
cout << endl << endl;
return 0;
}
(float getarray[][QUARTER], int divisions)
{
cout<<"\t\t\t\tQ1\tQ2\tQ3\tQ4\n";
for (int i = 0; i < divisions; i++)
{
cout << "Sales for Division " << (i+1) << " are: \t";
for (int j=0; j < QUARTER; j++)
cout << getarray[i][j] << "\t";
cout << endl;
}
}