You are using a version without Ads of this website. Please, consider donating:

### Prime numbers over 1000

I tried making an array of 30...but nothing is coming out. Tried a combination of a while/for loop...but I think I'm confusing the program. Can I get some assistance, please?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354`` ``````#include "stdafx.h" #include #include using namespace std; int main() { int N[30], *pN; pN = N; PrimeArray(pN,30); PrimeArrayDisplay(pN, 30); return 0; } void PrimeArray(int *PrArray, int Number) { int i, k, prime; i = 0; while (1 < Number) { prime=2; int limit = sqrt(double(prime)); for (k = 2; k <= limit; k++) { if (limit % k == 0) { break; } } if ( k == limit) { *PrArray++ = prime; i++; } prime++; } } void PrimeArrayDisplay(int *PrArray, int Number) { cout << "Display 30 Prime Numbers > 1001"; int i; i = 0; while (k < Number) { cout << "\n\t\t\tThe array N[" << setw(2) << i << "] = " << *PrArray++; i++; } }``````
Wow everyone is working on Prime numbers today.
Have a look at:
http://www.cplusplus.com/forum/beginner/98616/
and
http://www.cplusplus.com/forum/general/98431/

Where I have just posted enough code to answer your question :)
ok...I'm new so I haven't searched far. Thanks Zaita.
Topic archived. No new replies allowed.