### Trying to display the prime numbers between 1 - 100

Hello, I'm a beginner at C++ and am having some difficulty attempting to create a program for my C++ class that involves listing the prime numbers between 1 and 100.

I intend to have the numbers 1-100 listed, and cout statements to display which numbers are prime and which aren't. Such as this:

 ``` 1 is prime 2 is prime 3 is prime 4 is not prime 5 is prime 6 is not prime 7 is prime 8 is not prime 9 is not prime 10 is not prime```

etc.

or maybe you could help me put it into a more more efficient format?

 ``12345678910111213141516171819202122232425`` ``````#include #include using namespace std; int main() { int i, j; bool isprime; for(i=1; i<100; i++){ isprime= true; for(j=2; j<=i/2; j++);{ if(i%j); == 0 isprime = false; if(isprime) cout << " Is prime!"; return 0; } } }``````
Last edited on
I attempt to run it and get the error

Line 17: "Error 1 error C2146: syntax error : missing ')' before identifier 'isprime'
I do not know how to make it more efficient, as in writing only one or two lines of code to display all numbers between 1-100 and if they are prime or not but I do have some advice. First, make a cout for if it is not prime. Secondly, when it says if(isprime)
cout << " Is prime!"; It should be cout << "Is prime: " << number (I think int i or j)
Topic archived. No new replies allowed.