write the prime no program in c++?

Answer Posted / darren chang

bool checkPrime(int input)
{
for(int i=2; i<(input/2); i++)
{
if((input%i)==0)
{
return false;
}
}
return true;
}

Is This Answer Correct ?    14 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is main a class in c++?

568


What is the role of C++ shorthand's?

681


What are pointer-to-members? Explain.

638


What does it mean to declare a destructor as static?

629


Name the debugging methods that are used to solve problems?

585






What is the latest c++ standard?

689


Explain the difference between c & c++?

594


What is std namespace in c++?

727


What is a singleton c++?

552


Can I create my own functions in c++?

605


Can we inherit constructor in c++?

593


Should a constructor be public or private?

542


What is purpose of new operator?

601


Differentiate between late binding and early binding. What are the advantages of early binding?

586


Explain what is polymorphism in c++?

630