Thread: Prime number
View Single Post
  #3 (permalink)  
Old December 18th, 2011, 09:00 PM
Kebugcheck Kebugcheck is offline
Registered User
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Talking Something can be amended

Code:
#include <iostream>
#include <math>

using namespace std;

int main()
{
cout <<"Enter a number:";
int num;
boolean isPrime = true;
cin >>;
for (int i = 2; i <= sqrt(num); i++)
{
if (num % i == 0) 
{
isPrime = false;
break;
}
if (isPrime)
cout <<"YES"<<endl;
else
cout <<"NO<<endl;
return 0;
}
Reply With Quote