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?
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)