In the declaration portion, #define y 10000000, the constant that is declared must be in the range of and int data type. You have to use #define y 100000 or rather use a long long int type of variable in the main() and use it.
But listen primes[y] will again crash as it is beyond the maximum allocated size. So try another solution!
It is correct that y is “too large”. The problem yout encounter is caused by trying to allocate a huge mount of memory on the stack (the place the local variables are stored) in the statement
int primes[y];
Memory allocation on the stack is typically limited to a few MB, that is to a few 100000 ints. Almost all the memory you can use (hundreds of MB) is accessible on the heap.
There are two remedies for this:
Use a global array instead: Define primes out of the main function
Use vector from the STL. While it has a small penalty in terms of speed (totally neglible for a one-time allocation as in this case) you can use for example a dynamically growing size of the vector.
In this case
vector primes(y,1);
will additionally take care of the initialization with the value 1 in all components.
One more thing: Don’t #define a short word like y, especially as a beginner. Use some longer name and use const int instead. Otherwise it will probably bite you someday.