I am a beginner of C++ programming. When I am learning the array, I copied a program from a book and cannot be executed. I don't know what is wrong? Please help me!!!
#include<iostream.h>
void main()
{
int max_element();
int n, a[10];
int max;
for(n=0; n<10; n ++)
cin>>a[n];
max=max_element(a, 10);
cout<<max;
}
int array[], size;
int max_element(array,size)
{
int temp, j;
temp = array[0];
for(j=0; j<size; j++)
if(temp<array[j]) temp=array[j];
return temp;
}
The errors are
'max_element' : function does not take 2 parameters
<Unknown>' : function-style initializer appears to be a function definition