write the prime no program in c++?

Answer Posted / md.irfan(rourkela)

#include<iostream.h>
#include<conio.h>
main()
{
int n,i,f=1;
cout<<"enter any no to check prime";
cin>>n;
for(i=2;i<n;i++)
{
if(n%i==0)
k=2;
}
if(k==2)
cout<<"the no is not prime"<<endl;
else
cout<<"the no is prime";
}
getch();
}

Is This Answer Correct ?    145 Yes 91 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What kind of jobs can I get with c++?

592


Using a smart pointer can we iterate through a container?

559


What is a unnitialised pointer?

529


What is malloc in c++?

555


Explain the difference between overloading and overriding?

609






What is the purpose of template?

605


Does c++ have a hash table?

539


If I is an integer variable, which is faster ++i or i++?

588


When do you call copy constructors?

647


Can non graphic characters be used and processed in C++?

701


Differentiate between the message and method in c++?

606


Describe the advantages of operator overloading?

575


Do inline functions improve performance?

642


How many types of classes are there in c++?

590


What are default parameters? How are they evaluated in c++ function?

663