Its been a little while since i have used Dani Web but i need some help. If the code looks a little off then you have to forgive me. I was getting help from a friend who i found knew less about it then me.
Here is the criteria for the code:
-Write a function named findMax()that finds and returns the maximum value in a two-dimensional array of integers.
-The 3-row-by-4-column array in main()should be declared as:
int numbers[3][4] = {8, 16, 9, 52, 3, 15, 27, 6, 14, 25, 2, 10};
Here is my current code however it has a multitude of errors due to my getting lost from help that didnt understand.
#include <iostream>
#include <iomanip>
using namespace std;
int findMax int([][4]);
int main()
{
const int j = 3;
const int k = 4;
int i,u;
int max;
int numbers[j][k];
int numbers [3][4];
for(i=0; i<j; i++)
{
cout << endl;
for(u=0;u<k;u++)
{
int numbers[i][u]= {8, 16, 9, 52, 3, 15, 27, 6, 14, 25, 2, 10};
cout << setw(4) << numbers [i][u];
}
}
max = findMax(numbers);
cout <<"The max value is " << max << "\n\n";
return 0;
}
int findMax(int numbers[][4])
{
int i, u;
int j = 3;
int k = 4;
int max = 0;
for(i=0;i<j; i++)
for(u=0; u<k; u++)
{if (max < numbers[i][u])
max = numbers[i][u];
}
return max;
}
I would greatly appreciate anyone who can help me correct this.