write the prime no program in c++?

Answer Posted / suresh kumar

#include<iostream.h>
#include<conio.h>
void main()
{
int n,k,i=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 ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate between realloc() and free().

592


What should main() return in c and c++?

524


When do we run a shell in the unix system? How will you tell which shell you are running?

554


What does int * mean in c++?

633


What are member functions used in c++?

554






What is runtime polymorphism in c++?

585


What are pointer-to-members in C++? Give their syntax.

617


How do you flush std cout?

566


Can we inherit constructor in c++?

584


What are the various storage classes in C++?

646


What is private inheritance?

596


What is function prototyping?

620


What is a namespace in c++?

595


Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)

1486


Is c++ double?

559