The problem is that you are declaring a variable size array which is not allowed in C++.
When declaring an array in C++:
int i[size];
The variable size must either be a constant integral value
In order to create a C++ array with a variable size you need to use dynamically allocated memory:
int* i;
i = new int[size];
Now size can be a variable.
The problem is of course that not only is i not a pointer and has to be used as such, it also has to be deallocated later or you will have memory leaks, i.e. memory space your program has technically reserved but isn't using for anything.
More on dynamic memory here.