Hi

Do you find the below given code correct? Any suggestions?

One major problem is that the prime's state true or false is shown with "1" or "0" respectively. How do I get output such as "the number is prime" and "the number is not prime"? Please help me. Thanks a lot.

Code:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int n, i;
bool prime;
cout << "Enter the number: ";
cin >> n;
for (i=2; i<=(n/2);i++)
{
if (n%i != 0)
prime = true;
else
prime = false;
{
if (prime = false)
break;
}
}
cout << prime << endl;
system("pause");
}