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 is iostream in c++ used for?

554


Is java as fast as c++?

604


Is it possible to provide special behavior for one instance of a template but not for other instances?

636


What is the return value of the insertion operator?

607


Why do we need function?

605






Explain the register storage classes in c++.

674


Which software is best for programming?

666


What is an adaptor class or wrapper class in c++?

609


Write a program to add three numbers in C++ utilizing classes.

627


Is c++ free?

586


How can we read/write Structures from/to data files?

621


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

602


Can we specify variable field width in a scanf() format string? If possible how?

666


What does new in c++ do?

573


Do you know the use of vtable?

638