All functions compile except the max function where i am trying to get it to find the maximum number in the matrix. The error message says overloaded function with no contextual type information Please tell me why.

#include <iomanip>
#include <iostream>
using namespace std;


      const int ROW = 3; //global const for # of rows
      const int COL = 3; //global const for # of columns
      const int LOW = 1; //lower limit
      const int UP = 10; // upper limit
      const int LOWer = 10; //global const for the lower limit
      const int UPer = 100; //global const for the upper limit

// Function prototypes:
void ZeroArray(int[][COL], int, int); //function prototype
void PrintArray(int[][COL], int, int); //function prototype
void GenerateArray(int[][COL], int, int, int, int); //function prototype
int SumArray(int[][COL], int, int); //function prototype
int FindMax(int[][COL], int, int); //function prototype



int main(void)
   
   {
   
  int table[ROW][COL]; //array declaration 
  int total;           //return from function 
  int min;             //return from function 
ZeroArray(table, ROW, COL); //function call
PrintArray(table, ROW, COL); //function call
srand(time(NULL)); 
GenerateArray(table, ROW, COL, LOWer, UPer); 
total = SumArray(table, ROW, COL); //function call


//problem with max findmax is here 

max = FindMax(table, ROW, COL); //function calll   

   return 0;
   }

//zero out

           void ZeroArray(int t[][COL], int row, int col){
          for (int r = 0; r < row; r++)
              for (int c = 0; c < col; c++)
                 t[r][c] = 0;
      }

    //random
    void GenerateArray(int t[][COL], int row, int col, int lower_limit, int upper_limit){
    for (int r = 0; r < row; r++)
        for (int c = 0; c < col; c++)
            t[r][c] = rand()%(upper_limit - lower_limit + 1) + lower_limit;
}

    //print

    void PrintArray(int t[][COL], int row, int col){
        for (int r = 0; r < row; r++){
            for (int c = 0; c < col; c++)
               cout << setw(5) << t[r][c];
            cout << endl;
        
}

}

//sum 

      int SumArray(int t[][COL], int row, int col){
          int sum = 0;
          for (int r = 0; r < row; r++)
              for (int c = 0; c < col; c++)
                 sum = sum + t[r][c];
          return sum;
      }
      



      //max
      
            int FindMax(int t[][COL], int row, int col){
          int max = t[0][0];
          for (int r = 0; r < row; r++)
              for (int c = 0; c < col; c++)
                 if(t[r][c] > max)
                     max = t[r][c];
          return max;
      }

You forgot to declare max

thanks everything compiles now. I have another question I can not make system("PAUSE"); work. In other words how would I put system pause at the end of my code to make it show my results?

system("pause") isn't really a good method to use anyway, as it makes your code non-portable and you're using way more system resources than you need to.

Instead, use the get member function of cin:

cin.get();

I'm always just a little taken aback by things like getch(); and system( "pause" ); stuck in people's code. It is non-portable and in the case of getch() and cin.get(), leaves the input in an indeterminate state. Since the standard input is line bufferered, the most robust code would be something like: while (cin.get() != '\n'); ...which would read and discard anything typed until the ENTER key is pressed.

Even so, IMAO you shouldn't need to put such things in your code... The IDE should be able to do it for you or just run it from the command line as it was designed...

/me puts soapbox away

what? This is my code. It all compiles but I cant get it to show me a result. Does anyone see anything wrong with it. I wrote it myself and I think I did it right but dont know for sure and it is due tomorrow.

#include <iomanip>
#include <iostream>
using namespace std;


      const int ROW = 3; //global const for # of rows
      const int COL = 3; //global const for # of columns
      const int LOW = 1; //lower limit
      const int UP = 10; // upper limit
      const int LOWer = 10; //global const for the lower limit
      const int UPer = 100; //global const for the upper limit

// Function prototypes:
void ZeroArray(int[][COL], int, int); //function prototype
void PrintArray(int[][COL], int, int); //function prototype
void GenerateArray(int[][COL], int, int, int, int); //function prototype
int SumArray(int[][COL], int, int); //function prototype
int FindMax(int[][COL], int, int); //function prototype



int main(void)
   
   {
   
  int table[ROW][COL]; //array declaration 
  int total;           //return from function 
  int min;             //return from function 
  int max;
ZeroArray(table, ROW, COL); //function call
PrintArray(table, ROW, COL); //function call
srand(time(NULL)); 
GenerateArray(table, ROW, COL, LOWer, UPer); 
total = SumArray(table, ROW, COL); //function call
max = FindMax(table, ROW, COL); //function calll   

   return 0;
   }

//zero out

           void ZeroArray(int t[][COL], int row, int col){
          for (int r = 0; r < row; r++)
              for (int c = 0; c < col; c++)
                 t[r][c] = 0;
      }

    //random
    void GenerateArray(int t[][COL], int row, int col, int lower_limit, int upper_limit){
    for (int r = 0; r < row; r++)
        for (int c = 0; c < col; c++)
            t[r][c] = rand()%(upper_limit - lower_limit + 1) + lower_limit;
}

    //print

    void PrintArray(int t[][COL], int row, int col){
        for (int r = 0; r < row; r++){
            for (int c = 0; c < col; c++)
               cout << setw(5) << t[r][c];
            cout << endl;
        
}

}

//sum 

      int SumArray(int t[][COL], int row, int col){
          int sum = 0;
          for (int r = 0; r < row; r++)
              for (int c = 0; c < col; c++)
                 sum = sum + t[r][c];
                 cout << "The sum of the matrix is"  << sum;          
          return sum;
      }
      
      //max
      
            int FindMax(int t[][COL], int row, int col){
          int max = t[0][0];
          for (int r = 0; r < row; r++)
              for (int c = 0; c < col; c++)
                 if(t[r][c] > max)
                     max = t[r][c];
          cout << "The maximum number in the matrix is" << max;
          return max;
      }

Ehem...

Do one of the following:

1. Tell your IDE that you are compiling a console application --it should be smart enough to wait for you to read the console before the window disappears. If it can't do that:

2. Run your program from the command prompt. Or.

3. Use while (cin.get() != '\n'); instead of system().


[EDIT]
Yoinks...

I just tested your code and it works fine for me.

You might want to put a PrintArray() after you GenerateArray() just to see what the generated array was before printing out information.

Also, don't forget spacing and newlines in your output. For example, in sumArray() you should have: cout << "The sum of the matrix is " << sum << endl; And stick that while loop I gave you before the return statement in main().

Hope this helps.

how do i run from command prompt and what is command prompt what is system() and what does

Tell your IDE that you are compiling a console application --it should be smart enough to wait for you to read the console before the window disappears. If it can't do that:

mean

Are you doing this for school or just for your own learning?

You are the one who asked about system("pause"); in your second post. How is it you are writing a command-line application and not know what the command line is or how to access it? Go hit your teacher over the head.

Are you doing this for school or just for your own learning?

You are the one who asked about system("pause"); in your second post. How is it you are writing a command-line application and not know what the command line is or how to access it? Go hit your teacher over the head.

I am doing it for school and yes I would like to hit my teacher over the head. He doesn't teach very well.

:icon_lol: Yeah, a lot of beginning-programming teachers are like that.

Glad to be of help. :icon_cheesygrin:

i cant figure out how to find out how many times the maximum number occurred and my matrices are on top of each other

please post your latest code

can i delete this whole thread to protect my code from being viewed by teacher

Please format your code. It's really hard to follow.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.