I am trying to find the smallest numbers for each row. I can't figure out what I'm doing wrong, as my cout statement seems like it should be after the first for loop is completed. If anyone has any suggestions please let me know. I have bolded the section that is giving me problems.
#include <iostream>
using namespace std;
int main()
{
const int NUM_ROW = 2;
const int NUM_COL = 2;
double average, total, smallest = 400;
double food[NUM_ROW][NUM_COL];
cout << "Please enter the amount of food eaten per day "
<< "for the 3 different monkeys";
for(int row = 0; row < NUM_ROW; row++)
{
for(int col = 0; col < NUM_ROW; col++)
{
cin >> food[row][col];
}
}
for(int row = 0; row < NUM_ROW; row++)
{
for(int col = 0; col < NUM_COL; col++)
{
total += food[row][col];
average = (total / (NUM_ROW * NUM_COL));
}
} for(int row = 0; row < NUM_ROW; row++)
{
for(int col = 0; col < NUM_COL; col++)
{
if(smallest > food[row][col+1])
smallest = food[row][col+1];
}
cout << "The smallest amount of food for monkey # "<< row+1 << "is: "<< smallest << endl;
}
cout << "The average the family eats is: " << average << endl;
//for(int row = 0; row < NUM_ROW; row++)