Program to Find the Prime Number
#include<iostream.h>
#include<conio.h>
int main()
{
int num,n=0;
int num,n=0;
cout<<"Enter the number: ";
std::cin>>num;
for(int k=1;k<=num;k++)
{
if(num%k==0)
{
n++;
}
}
if(n==2)
{
std::cout<<"It is a Prime number"<<std::endl;
}
else
{
std::cout<<"It is not a Prime number "<<std::endl;
}
getch();
return 0;
}
No comments :
Post a Comment