Highest Per Column in an Array

Hey guys, i'm new in C++ coding and I need some help with a programming challenge i was assigned. I am so confused on just how to do the highestPerQuarter function.

My code so far is:
#include <iostream>
using namespace std;

//Function Prototypes
void fillArray(int sales[][COLS]);
void incorDec(int sales[][COLS]);
void displayArray(int sales[][COLS]);
void totPerQuarter(int sales[][COLS]);
void highPerQuarter(int sales[][COLS]);
double calcAverage(int sales[][COLS]);

int main()
{
//Make Vars
double average;

//Make 2D Array
int sales[ROWS][COLS];

//Call Functions
fillArray(sales);
incorDec(sales);
displayArray(sales);
totPerQuarter(sales);
highPerQuarter(sales);
average = calcAverage(sales);
}

void fillArray(int sales[][COLS])
{
cout << "Enter sales figures for each Quarter and each Divison: ";
for(int r = 0; r < ROWS; r++)
{
for(int c = 0; c < COLS; c++)
{
cout << "Divison " << r+1 << "Quarter " << c+1 << ":";
cin >> sales[r][c];

//Input Validation
if(sales[r][c] < 0)
{
cout << "You have entered an invalid number, try again."
}
}
}
}

void incorDec(int sales[][COLS])
{
cout << "Increase or Decrease in sales figures for each Quarter and Division: ";

for(int r = 0; r < ROWS; r++)
{
for(int c = 0; c < COLS; c++)
{
if(sales[r][c] - sales[r][c+1] < 0)
{
cout << "Increasing.";
}

else if(sales[r][c] + sales[r][c] > 0)
{
cout << "Decreasing.";
}

else
{
cout << "They are equal."
}
}
}
}

void totPerQuarter(int sales[][COLS])
{
for(int c = 0; c < COLS; c++)
{
int total = 0;
for(int r = 0; r > ROWS; r++)
{
total += sales[r][c];
}
cout << "Total: " << total << endl;
}

}

void highPerQuarter(int sales[][COLS])
{

}

double calcAverage(int sales[][COLS])
{
//Make Vars
int total = 0;
double avrg;

for(int r = 0; r < ROWS; r++)
{
for(int c = 0; c < COLS - 1; c++)
{
total += sales[r][c];
}
}
return (double)(total) / (ROWS * COLS);
}

void displayArray(int sales[][COLS])
{
cout << "Sales figures for each Quarter and each Division: ";

for(int r = 0; r < ROWS; r++)
{
for(int c = 0; c < COLS - 1; c++)
{
cout << " Division " << r+1 << "Quarter " << c+1 << ":" << sales[r][c];
}
}
Topic archived. No new replies allowed.