I have the following question for a bonus assignment:
Write a program in C++ that asks the user to enter an array of size N and find index of the largest value in that array using a function named largest_location that takes an array of integer values and an integer that tells how many integer values are in the array as arguments. The function should return as its value the index of the cell containing the largest
of the values in the array. Do not forget to write the main function as well. Your main function should get the array from the user and pass it to the function largest_location. Print the index of the largest location in the main function.
I almost completed it, then I realized that I was just doing the greatest number in the array instead of the index number. I just need help outputting that "index 3 has the highest number of..." This is the code I have written that works(except for what the index number is)
if(array[i]>temporary){
temporary=array[i];}
}
cout << "The largest location in the array is "<<temporary;
}
int main()
{
int arraylength;
cout<<"Enter the array size: ";
cin>>arraylength;
float* array = new float[arraylength];
cout<<"Enter the numbers in the array:" << endl;
for (int i=0; i<arraylength; i++){
cin >> array[i];
}
largest_location( array, arraylength );
}