Hi again,
I've figured out how to get the program to do what I need it to do, except it is doing the last thing twice and I can't figure out how to change it so it does it only once. Please provide some direction. I've attached the files.

Attachments
#include <iostream>
#include <iomanip>
#include <cstdlib>



using namespace std;
const int numberOfRows = 2;
const int numberOfColumns = 12;

void getData(int matrix[][numberOfColumns], int noOfRows);
void avgHigh(int matrix[][numberOfColumns], int noOfRows);
void avgLow(int matrix[][numberOfColumns], int noOfRows);
void indexHighTemp(int matrix[][numberOfColumns], int noOfRows);
void indexLowTemp(int matrix[][numberOfColumns], int noOfRows);
void pause ( );

int main ()
{
   int temps[numberOfRows][numberOfColumns];
                    
   
    
    getData(temps, numberOfRows);        
  
                    
    avgHigh(temps, numberOfRows);            
    cout << endl; 
    avgLow(temps, numberOfRows);
    cout << endl;
    indexHighTemp(temps, numberOfRows); 
    cout << endl;
    indexLowTemp(temps, numberOfRows);
    pause ( );    
    
     return 0;
     } 
     void getData(int matrix[][12], int rowSize)
{
       cout<<"Enter high temperature for each month"<<endl; ; 
    for (int rows=0; rows<1; rows++)
         for (int cols =0; cols<12; cols++)
         {  
           cin>>matrix[0][cols];
           cout<<matrix[0][cols];
           cout<<endl;
           }
           
     
     cout<<"Enter low temperatures for each month"<<endl;
     
     for (int rows=0; rows<1; rows++)
         for (int cols =0; cols<12; cols++)
         {  
           cin>>matrix[1][cols];
           cout<<matrix[1][cols];
           cout<<endl;
           }           
}
void avgHigh(int matrix[0][12], int rowSize)
{
    int rows, cols;
    int sum;
    int average;
    
       for (rows = 0; rows < 1; rows++)
    {
        sum = 0;

        for (cols = 0; cols < 12; cols++)

  
        sum = sum + matrix[rows][cols];
        average=sum/12;

     

        cout << "Average high temperature: " << average<<endl;
      
}
}  
void avgLow(int matrix[1][12], int rowSize)
{
    int rows, cols;
    int sum;
    int average;
    
       for (rows = 0; rows < 1; rows++)
    {
        sum = 0;

        for (cols = 0; cols < 12; cols++)

  
        sum = sum + matrix[1][cols];
        average=sum/12;

     

        cout << "Average low temperature: " << average<<endl;
}     

}
void indexHighTemp(int matrix[][12], int rowSize)
{
    int rows;
    int cols;
    int highest;

        
    for (rows = 0; rows < rowSize; rows++)
    {
       highest = matrix[rows][12]; 
       for (cols = 1; cols < 12; cols++)
           if (highest < matrix[rows][cols])
              highest = matrix[rows][cols];

       cout << "The highest temperature is: " << highest<< endl;
    }
}
void indexLowTemp(int matrix[][12], int rowSize)
{
    int rows;
    int cols;
    int lowest;

        
    for (rows = 0; rows < rowSize; rows++)
    {
       lowest = matrix[rows][12]; 
       for (cols = 1; cols < 12; cols++)
           if (lowest > matrix[rows][cols])
              lowest = matrix[rows][cols];

       cout << "The lowest temperature is: " << lowest<< endl;
    }
}
void pause()
{
	cout << endl;
	cout << "Enter a character to quit --> ";                   //
   char dummy;
   cin >> dummy;                                     // Wait
}

If you mean why are the low and high temps shown twice - it's because in those function you have the loop running two iterations. In fact, what you show are the highest high and the highest low, and the lowest high and the lowest low.

Also, in both the indexXXXTemp functions, you initially set your min/max to the value at column index 12. That's out of bounds for the arrays! Better option in any min/max problem is to set the min/max variable to the very first element of the data set. This then solves the problem for the smallest set - that consisting of a single element.

Several places you have an outer loop for (rows = 0; rows < 1; rows++) - this is useless, as it runs only one iteration. You might as well remove this, or, let the outer loop do its job and run for both rows, using its counter as the row index.
Val

(good guess, Walt, but it wasn't the problem in this case. I'd have thought the same thing.)

(good guess, Walt, but it wasn't the problem in this case. I'd have thought the same thing.)

OK. I, like many others here, don't download links. The code must be posted. And preferably not 500 lines, just the section in question...

Ok,
Thanks for the direction Val and for not trying to make me feel like a complete idiot. And Walt, I am sorry if I don't know the proper etiquette for posting. I am learning. Hopefully, I'll get to the point where I can stop asking for help and start providing some help. But when and if I do, I want to remember where I started, it'll help keep me humble.

And Walt, I am sorry if I don't know the proper etiquette for posting. I am learning.

All it takes is reading the Rules and the sticky posts at the top of the forum...

This article has been dead for over six months. Start a new discussion instead.