Please help to check and explain the error please.
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int maxIndex(int a[], int n);
int main()
{
const int max_size = 30;
int list[max_size];
int n;
cout<<"Enter size of array:";
cin>>n;
//input numbers into array
for(int i = 0; i < n; i++)
{
cin>>list[i];
}
cout<<"The largest integer entered was "<< maxIndex(list[], n)<<endl;
system("pause");
return 0;
}
int maxIndex(int a[], int n)
// Pre: n > 0, and the array elements a[0], a[1], ..., a[n-1]
// contain integer values.
// Post: returns the index of the first occurrence of the
// largest element of a[0..n-1].
{
int k = 0;
int i = 1;
while (i < n)
{
if (a[i] > a[k])
k = i;
i++;
}
return k;
}
when i compile the code, the error stated on the red colour.
thank you