#include <iostream>
#include <vector>
#include <ctime>
#include <stdlib.h>
using namespace std;
void displayArray(int elements[][5], int numCol, int numRow) {
for (int row = 0; row < numRow; row++) {
for (int col = 0; col < numCol; col++) {
cout << elements[row][col] << " ";
}
cout << endl;
}
}
int findMin(int arr[], int n) {
int mini = arr[0];
for (int i = 0; i < n; i++) {
if (arr[i] < mini) {
mini = arr[i];
}
return { mini };
}
}
int findMax(int arr[], int n) {
int maxi = arr[0];
for (int i = 0; i < n; i++) {
if (arr[i] > maxi) {
maxi = arr[i];
}
}
return { maxi };
}
int main()
{
const int numCol = 5;
const int numRow = 5;
int elements[numCol][numRow] = { { 81, 27, 83, 89, 92}, {87, 76, 84, 98, 99}, {83, 47, 89, 42, 48}, {75, 96, 76, 34 ,38}, {98, 83, 76, 27, 29} };
int N = sizeof(elements) / sizeof(elements[0]);
displayArray(elements, numCol, numRow);
cout << "Minimum is: " << findMin(elements, N);
}
So currently, when executing this code I get an error specifying that my parameters are incompatible C++ argument of type is incompatible with parameter of type. I'm currently stuck as to why I'm getting this issue. My hypothesis is that I cannot do this with a normal array, and may have to use a vector array in order to, achieve the end goal of producing the smallest number in the array and the largest.