Q: tests all the numbers from 2 to 10 (inclusive) and prints out the
results, each on a separate line. (Hint: Use a for loop, with i running from 2 to 20.)
Desired output:
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
int n = 20
for (int i = 2; i < length of the sequence of numbers you want to test, in our case, n; i++)
{
if (//Condition where you test for a prime number e.g. for a condition like i == 1)
{
//cout statement stating the number you tested and that it was found to be prime
}
else
{
//cout statement where you say the number isn't a prime number
}
}