C++ language

adplus-dvertising
Program To Find Out Whether Number Is Prime Or Not
Previous Home Next

Program To Check Whether The Number Is Prime Or Not Using C++

#include<stdio.h>
#include<conio.h>
void main()
{
int num,a=1;
cout<<"\n Enter the number";
cin>>num;
for(int i=2;i<num/2;i++)
{
if(num%i==0)
p=p*0;
	else
p=p*1;
}
}
if(p!=0)
cout<<"\n number is prome";
else
cout<<"\n number is not prime";
}

Output:

Enter the number
6
number is not prime
Previous Home Next