C++ Program to find prime numbers between 2 and 10,000

I need help i need to develop a program in C++ that prints all prime number between 2 and 10,000. All i have so far is not working out.
``````#include <iostream>

using std::cout;
using std::endl;

#include <iomanip>
using std::setw;

int primo();// funcion prototipo

int main()
{
cout << "Los numeros primos entre 2 a 10,000 son: " << endl;
primo();
system("pause");
return 0;
}

int primo ()// La funcion primo
{
int x;
int y;
int z;

for( x = 2; x <= 10000; x++)
{
for( y = 2; y <=(x-1); y++)
{
z = x % y;

if( z == 0)
z =(x+1)% y;
else
{
cout << x << endl;
}
}
}
}
``````
Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi, try this one:

Not tested..... But I think it should work.
``````#include <iostream>
#include <math.h>
using namespace std;

int numMin = 2;
int numMax = 10000;
int pt = 0;
bool is_prime;

int main()
{

while (numMin <= numMax)
{
is_prime = true;
for (pt = 1; pt <= sqrt(numMin); pt++)
{
if (numMin % pt == 0)
is_prime = false;
}
if (is_prime)
cout << numMin << endl;
i++;
}
return 0;
}
``````

Experts Exchange Solution brought to you by