Need Help with program

Problem is the program is supposed to search through the table and pull out the highest value, and cout the Division that its in. I'm having problems with highest and lowest output

#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

#define ROW 5
#define COLS 5

double getTotal(double[][COLS]);
double getAverage(double[][COLS]);
double getRowTotal(double[][COLS], int);
double getColumnTotal(double[][COLS], int);
double getHighest(double[][COLS], int&, int&);
double getLowest(double[][COLS], int&, int&);

int main()
{
int r, c, row, col;
double val;
double sales[ROW][COLS] = { 0 };
string division[4] = { "North", "South", "East", "West" };

for (r = 0; r < 4; r++)
{
cout << endl << "Please enter 4 quarter sales amounts for the " << division[r] << " Division.\n" << endl;

for (c = 0; c < 4; c++)
{
cout << "Enter quarter " << c + 1 << ": ";
cin >> sales[r][c];
}
}

for (r = 0; r < ROW - 1; r++)
sales[r][COLS - 1] = getRowTotal(sales, r);

for (r = 0; r < COLS; r++)
sales[COLS - 1][r] = getColumnTotal(sales, r);

cout << endl;
cout << "\tQtr 1\tQtr 2\tQtr 3\tQtr 4\tDivision Total\n";
cout << endl;


for (r = 0; r < ROW; r++)
{
if (r == (ROW - 1))
cout << "Qtr sum\t";
else
cout << division[r] << "\t";
for (c = 0; c < COLS; c++)
cout << "$" << sales[r][c] << "\t";
cout << endl;
}

cout << endl;
cout << "Average of all sales: " << getAverage(sales) << endl << endl;


val = getHighest(sales, row, col);
cout << "Highest sale: Division " << division[row] << " quarter " << col + 1 << " $" << val << endl;


val = getLowest(sales, row, col);
cout << "Lowest sale: Division " << division[row] << " quarter " << col + 1 << " $" << val << endl;


system("pause");
return 0;
}

double getTotal(double x[][COLS])
{
int r, c;
double val = 0;
for (r = 0; r < ROW - 1; r++)
for (c = 0; c < COLS - 1; c++)
val += x[r][c];
return val;
}

double getHighest(double num[][COLS], int& row, int& col)
{
int c, r;
double val;
val = num[0][0];
for (r = 1; r < ROW - 1; r++)
for (c = 0; c < COLS - 1; c++)
if (num[r][c] > val)
{
val = num[r][c];
row = r;
col = c;
}
return val;
}

double getAverage(double t[][COLS])
{
return getTotal(t) / ((ROW - 1)*(COLS - 1));
}

double getLowest(double num[][COLS], int& row, int& col)
{
int c, r;
double val;
val = num[0][0];
for (r = 1; r < ROW - 1; r++)
for (c = 0; c < COLS - 1; c++)
if (num[r][c]<val)
{
val = num[r][c];
row = r;
col = c;
}
return val;
}

double getRowTotal(double num[][COLS], int n)
{
int r;
double val = 0;
for (r = 0; r < COLS - 1; r++)
val += num[n][r];
return val;
}

double getColumnTotal(double num[][COLS], int n)
{
int r;
double val = 0;
for (r = 0; r < ROW; r++)
val += num[r][n];
return val;
}

Don't just store the largest/smallest value - store its position too.
Could you elaborate further.
When you are going through to find the lowest and highest values, each time you update them you should also update the positions you found them.
Truly have no idea how to do that. Can you show me?
Look ate your getLowest function. Tell me which lines you think are responsible for keeping track of the lowest value found so far.

By the way, you should edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting as well as proper indentation.
Topic archived. No new replies allowed.