write the prime no program in c++?

Answer Posted / pramod k sharma

#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 ?    14 Yes 32 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate between an array and a list?

934


Is the declaration of a class its interface or its implementation?

943


What is the use of :: operator in c++?

817


What is object oriented programming (oop)?

859


When are exception objects created?

794


an operation between an integer and real always yeilds a) integer result b) real result c) float result

944


What do you mean by funtion prototype?

813


Can notepad ++ run c++?

740


What is the use of setfill in c++?

800


How do I use arrays in c++?

769


Do class declarations end with a semicolon?

796


What is an html tag?

830


What is const in c++?

809


Define pure virtual function?

743


Explain what you mean by a pointer.

853