I am looking for some assistance on my code. Right now I have to take a text file with a first name, last name, and the number of movies they have seen. I have all my variables defined in the main function and all the math and reading of the code in other functions. I have three separate arrays, fName, lName, arr (which holds the number of movies) Right now I am struggling. I need to be able to find the index, or position of the min and max in the arr array. This is the code I have so far, remember, everything is declared and already used in the main function (except for position)
1 2 3 4 5 6 7 8 9 10 11 12 13
void minAndMaxFunction(int arr[], string fName[], string lName[], int& min, int& max, int siz, int position) {
for (int i = 0; i < siz; i++) {
if (min > arr[i]) {
min = arr[i];
}
if (arr[i] > max) {
max = arr[i];
}
}
The min and max come out correctly but I need to figure out where in the arr they are stored like min is technically stored in line 8, arr index 7 and max is stored on line 9 index 8. How do I go about doing this?