0

OK, first off I have figured out the prime number algorithm...I guess.

What I am needing help with, or wanting the answer to, is how to count how many primes are being displayed. To wit:

Enter a Number: 10

There are 4 Primes. The Primes are:

7 5 3 2

Do you want to continue (y/n)?

This is what I have so far

```
#include <iostream>
using namespace std;
int main()
{
int x; // input
int y; // divisor
int z; // prime
char key; // to continue or not
cout << "This program will allow you to enter a number and will display all and how many prime numbers from that number to 0." << endl << endl;
do
{
cout << "Please enter a number: ";
cin >> x;
cout << endl;
// cout << "There are " << counter << " primes in that range." << endl;
cout << "All primes in this range are:" << endl << endl;
for (z=x; z>=2; z--)
{
bool primeNo = false;
for (y=2; y<z; y++)
{
if (z % y == 0)
{
primeNo = true;
}
}
if (primeNo == false)
{
cout << z << " ";
}
}
cout << endl << endl;
cout << "Continue (y/n)? ";
cin >> key;
}
while (key == 'y'||key == 'Y');
cout << endl << endl;
system("PAUSE");
return 0;
}
```

Thanks for your help!