Here is a little of my program:
struct Town
{
int population, outbreaks;
};
const int MAX_ROWS = 39;
const int MAX_COLS = 39;
void GetInfRate(Town[][MAX_COLS], int);
//some other functions
int main()
{
Town coordinates[MAX_ROWS][MAX_COLS];
//I load my data
// I display menu, etc.
}
void GetInfRate(Town c[][MAX_COLS], int MAX_ROWS)
{
//this function needs to go through the array and display
//the coordinates of those who have an infection rate
//higher than 10%. I need to output the coordinates (row
//and col and the infection rate. It has a little note to
//"traverse the entire array (2 loops), compare result >
//10". I am very confused on what traverse means.
//Here is what I have and it's not working:
int popN, outN;
double result;
for (int row = 0; row < MAX_ROWS; row++)
for (int col = 0; col < MAX_COLS; col++)
{
popN = c[row][col].population;
outN = c[row][col].outbreaks;
if (popN > 0)
result = (outbreaks / population) * 100;
if (result > 10)
{
cout<<"Row: "<<row<<endl;
cout<<"Col: "<<col<<endl;
cout<<"Rate: "<<result<<endl;
}
}
}
What am i doing wrong?