I am trying to write a program that stores all the prime numbers up to 1000 in an array.. I can do that.. but when it's doing the check to see if it's prime, if it isn't, it just sets it to 0. So when I try to print out all my prime numbers, it prints all the 0s out with it. How do I remove the 0s from the array? Or what's a better way to do this..
But how would I just not store it in the array to begin with?
You have to store something in each element of the array, or else the program will store something for you (usually whatever information happens to be at the memory locations at compile time - and more often than not, that garbage is not condusive to a healthy program)