Here is the program which I have coded. I created a function "getMax" which returns the value of the maxima in an array. Then using this value I applied a for loop to find out the index of this maxima.
int main(){
int arr[10];
int Imax = 0;
cout << "enter the elements of the array of sise 10" << endl;
for (int j=0; j<10; j++)
cin >> arr[j];
int getMax(arr[10]);
for(int k=0; k<10; k++) {
if(arr[k]== getMax)
Imax+=1;
}
cout << "the index of the max element is" << Imax;
return 0;
}
int getMax(int arr[]) {
int max= 0;
for(int i=0; i<10; i++){
if (arr[i]>max)
max=arr[i];
return max;
}
}