There's another problem in this program:
The computer stores an
int using a fixed number of digits, which means that there's a minimum value and a maximum value that it int can represent.
A typical
int is (usually) made up of 32 digits, but these are always binary digits, or
bits, which alone can only represent two numbers - zero or one. 32 bits together can represent a total of 2^32 distinct values.
As a consequence, the largest number one can store in a int is 2^31 - 1 = 2147483647, and the smallest number is - (2^31) = -2147483648.
2^31 is
much smaller than the numbers you're attempting to store in your array. A program which puts a value larger than the maximum (or smaller than the minimum) into an
int is said to
overflow or
underflow the
int.
A program which does this is said to exhibit
undefined behavior, or
UB for short. UB always represents an error on the programmer's part. A program that contains UB may behave correctly, crash, output complete garbage, or silently fail in a subtle manner unrelated to the real issue. In the worst case, such a program may curse you with a case of nasal demons. You'll have to change your program to avoid storing overly-large numbers in your array.
http://catb.org/jargon/html/N/nasal-demons.html