Comment on Tutorial - Checking Prime Number in C++ By Grant Braught



Comment Added by : Anonymous

Comment Added at : 2013-02-27 05:38:27

Comment on Tutorial : Checking Prime Number in C++ By Grant Braught
This program is mush faster and finer than given program.



#include <iostream>
#include <math.h>

bool IsPrime(int number)
{
for (int i=2; i<sqrt(number/2); i++)
{
if (number % i == 0)
{
return false;
}
}

return true;
}
int main()
{
int number;

cout << \"Enter an integer: \";
cin >> number;

if (IsPrime(number))
cout << number << \" is prime.\" << endl;
else
cout << number << \" is not prime.\" << endl;

return 0;
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. sooooooooooooooooo gr8 jop!!
View Tutorial          By: monti at 2011-06-14 08:40:55

2. Very useful tutorial. But if same code is executed
View Tutorial          By: Jitendra Kumar Mahto at 2011-08-12 15:10:14

3. This is a great tutorial. I have a slight problem,
View Tutorial          By: Vix at 2010-11-22 13:42:03

4. sir i want to knw abt all simple java programs pls
View Tutorial          By: sakthi at 2011-08-29 14:06:10

5. Plz can someone help me, I copied the code above a
View Tutorial          By: Dse90 at 2010-02-10 04:28:34

6. Hello Everyone
I used this program but i'm

View Tutorial          By: Yougeshwar Khatri at 2011-09-16 08:50:47

7. nice one !!! just keep it .. i have learn a lot..
View Tutorial          By: dondon at 2011-07-27 04:43:40

8. detailed article.
I found this one better t

View Tutorial          By: Neo at 2013-05-04 16:42:12

9. what about asp.net?
View Tutorial          By: tradeready at 2009-05-06 03:04:20

10. I want to ask you a question...
I test the

View Tutorial          By: sara at 2009-05-15 13:16:54