This doubt is for Arrays- Max value in array
The code doesn’t work in the problem. I ran the same code in sublime and it works. The online editor shows run time error. I tried multiple test cases like positive and negative numbers. it worked in sublime. Could you please help me with this ?
this is my code:-
#include
#include
using namespace std;
int main() {
int n;
int i = 0;
cin >> n;
int arr[n];
while(i < n){
cin >> arr[i];
i++;
}
int max = -9999;
for (int i = 0; i < n; i++){
if(arr[i] > max){
max = arr[i];
}
}
cout << max;
}