Hello, I am a newbie a C++. I was doing a program where you calculate prime numbers, and it prints prime and non-prime numbers. Here is my code,
#include <iostream>
#include <conio.h>
using namespace std;
main()
{
int n = 1;
int i = 2;
bool IsPrime;
int Max;
int x = 0;
cout << "Maximum number: ";
cin >> Max;
while (x < Max)
{
IsPrime = true;
while ((i < n) &&)
{
if (n % i == 0)
{
// Is not prime
IsPrime = false;
}
else
{
// Is prime
i++;
}
}
if (IsPrime)
{
cout << "Prime: " << n << endl;
}
n++;
x++;
}
getch();
}
Thanks,
~mr. doughnuts