Hello guys, I'm trying to code a program where it asks the user to put a number represent the numbers in an array. The user then will enter the numbers in the array list.
I've made a few amendments. And the output is not like what I expect.
#include <iostream>
usingnamespace std;
void minmax(double *numbers, int npts, double *min_ptr, double *max_ptr);
int main()
{
int i, npts;
double min, max;
double arr[100];
cout << "How many numbers would you like to enter?" << endl;
cin >> npts;
cout << "Enter the " << npts << " numbers separated by whitespace." << endl;
for (i=0; i<npts; i++)
cin >> arr[i];
minmax(arr, npts, &min, &max);
cout << "The min is " << min << " and the max is " << max << endl;
return 0;
}
The array defined in main() is passed via the first parameter, double *numbers. You should not be defining an additional array inside the function minmax (line 7).
Assignment9_function.cpp: In function βvoid minmax(double*, int, double*, double*)β:
Assignment9_function.cpp:8:2: error: βarrβ was not declared in this scope
arr[npts];
^