I'm doing a function that returns the index of the largest integer in the array it's an easy function.I've done it but I don't know why the output is always 10 although i want to return only the index of the largest number and here is my code:
int MAX_INT(int arr[],int s)
{int temp;
for(int Index=0;Index<s;Index++)
{
if(arr[Index]<arr[Index+1])
temp =Index;
else
temp= Index+1;
}
return temp;
}
int main()
{
const int SIZE=10;
int arr[SIZE];
for(int i=0;i<SIZE;i++)
cin>>arr[i];
cout<<MAX_INT(arr,SIZE);
}
Thank you
:)