Help getting error on REVMEE (reverse a list of int)

using namespace std;

int main() {
int n;
int arr[n];
for(int i=1;i<=n;i++){
for(int i=0;i<n;i++){
    cout<<arr[i]<<" ";
return 0;

your are getting error because you
array size is not initialize

first read input for n

then initialize

int arr[n];

1 Like

Another case where just looking at compiler warnings would reveal the issue :slight_smile:

[~/devel/hackerrank/otherpeoples]>g++ -std=c++14 ninja_69o-REVMEE.cpp -O3 -g3 -Wall -Wextra -Wconversion 
ninja_69o-REVMEE.cpp: In function ‘int main()’:
ninja_69o-REVMEE.cpp:7:14: warning: ‘n’ is used uninitialized in this function [-Wuninitialized]
     int arr[n];
1 Like

Ah I see , accutually it was giving me correct output on compiler and error on submission , that’s why I got confused .kekw thanks

Oops, thanks