Max Value In array

#include
#include
using namespace std;

int maxvalue(int a[], int n)
{
int largest = INT_MIN;

for (int i = 0; i < n; i++)
{
    if (a[i] > largest)        
        largest = a[i];
} 

return largest;

}

int main()
{
int arr[1000],n,N;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>N;
}
cout<<maxvalue(arr, n);

return 0;

}

hello @heyiamtushar

here it should be cin>>a[i]; in place of cin>>N;

thank you so much !!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.