Hi everyone. I'm trying to write a code which will find and print out every prime number between 1 and 1000 using a 1000 element array (NOTE: I am not allowed to use the prime number function).

Problem is, my program outputs EVERY number from 1-1000. Please take a look at my program and help me fix it (im farely new to C++)

Code:// 4.29 // Prime Number #include <iostream> using std::cin; using std::cout; using std::endl; int main() { const int arraysize = 1000; int x, a[arraysize], b; for (x=0; x < arraysize; x++) a[x] = 1; for (x=2; x < arraysize; x++) { if ( arraysize ==1) { while ( b < arraysize ) { b = x; x = x + b; a[b] = 0; } } } a[1] = 0; cout << " here are your prime numbers from 1000 "; for (int c = 0; c < arraysize; c++) { if (a[c] = 1) cout << c << " "; } return 0;