The Code has no errors and is not failing any of the given test cases. However when I submit the code it showed that it failed test cases. Please point out any mistakes if present!
#include
using namespace std;
int max(int a[] , long long n)
{
long long max=0;
for(long long i=0 ; i<n ; i++)
{
if(a[max]<a[i])
{
max=i;
}
}
return(max);
}
int main() {
int a[100000];
long long n;
cout<<"Enter the number of Elements in the array: ";
cin>>n;
cout<<endl;
for(long long i=0 ; i<n ; i++)
{
cout<<endl<<"Enter element number "<<i+1<<" : ";
cin>>a[i];
}
int x=max(a,n);
cout<<endl<<"The greatest element is : "<<a[x]<<endl<<"At position : " <<x+1;
return 0;
}