I made that task but it turn to me a huge number not the maximum
my code is
#include <iostream>
using namespace std;
int* max(int p[],int n);
int main (){
int n;
int*A=new int;
int *p;
cout<<"enter the value of array";
cin>>n;
p=new int[n];
for(int i=0;i<n;i++){
cout<<"enter the element";
cin>>p[n];
}
A=(max(p,n));
cout<<"the maximum is"<<*A;
return 0;
}
int* max(int p[],int n)
{
int maximum;
maximum = p[0];
for(int x=0;x<n;x++)
{
if(p[x]>maximum)
{
maximum=p[x];
return &maximum;
}
}
return &maximum;
}