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;
}
}
}
}

Open in new window

arivillafaneAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

aherpsCommented:
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;
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
arivillafaneAuthor Commented:
you forgot to declare i
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.