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



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. this code is running successfully
View Tutorial          By: Amit Agarwal at 2013-03-08 10:56:39

2. wow... and Thanks...
View Tutorial          By: lasitha at 2010-07-24 21:38:50

3. HI all,

I am not able to call SMSC

View Tutorial          By: chinnadurai at 2009-08-26 23:58:54

4. Nice article, Thank you
View Tutorial          By: kumar kasimala at 2010-04-26 21:09:25

5. great work..keep it up.
View Tutorial          By: faizaan at 2011-04-29 12:23:39

6. Thanks a lot! This really helped!!!
View Tutorial          By: SuperSeppel13 at 2009-04-14 04:25:06

7. hey plzz help me the code is not working for me...
View Tutorial          By: kuldeep at 2014-02-24 18:16:59

8. its very helpful and understandable.thanq
View Tutorial          By: Deepika darapaneni at 2012-03-24 14:16:39

9. how about if you attach microsoft word documents?p
View Tutorial          By: gian at 2012-01-06 03:11:44

10. know someone how to compare various objects?

View Tutorial          By: Peter at 2009-10-07 07:32:31