Output is coming different on the online compiler and the code blocks

My code is printing zero but when i am running it on codeblocks it is working fine .
The code is given below:
#include
using namespace std;
int main() {
int n;
cin>>n;
float arr[n];
for (int i=0;i<n;i++)
{
cin>>arr[i];
}
float max =arr[0];
for (int j=1;j<n;j++)
{
if(max < arr[j])
{
max = arr[j];
}
}
cout<<max<<endl;
return max;
}

Hi @rakshitgangwar
In the int main function you should use return 0 because in c++ compiler return 0 means that programme has excetuted successfully.