write the prime no program in c++?

Answer Posted / swapnil

/*To check whethere Entered no. is PRIME or NOT*/
#include<iostream.h>
#include<conio.h>
main()
{
int num,i;
clrscr();
cout<<"Enter the any no.="<<"\n";
cin>>num;
for(i=2;i<=num;i++)
{
if(num%i==0)
{
break;
}
}
if(i==num)
{
cout<<"The number entered is a
PRIME no.";
}
else
{
cout<<"The number entered is NOT a
PRIME no.";
}
getch();
}

Is This Answer Correct ?    74 Yes 41 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do inline functions improve performance?

642


What is runtime polymorphism in c++?

584


What is :: operator in c++?

578


What is ios in c++?

642


What is array in c++ pdf?

554






What is #include iostream in c++?

589


What does the ios::ate argument do?

659


What are c++ tokens?

590


what is C++ exceptional handling?

627


Describe exception handling concept with an example?

556


What is vector processing?

666


Can you sort a set c++?

524


Which is the best c++ compiler?

585


Is ca high or low level language?

582


What gives the current position of the put pointer?

559