#include<iostream>
#include<process.h>
using namespace std;
int main()
{
int num,count=0;
cout<<"Enter a Number to Check prime or not: ";
cin>>num;
if (num < 0)
{
cout << "Plz Enter +ve Integer Value"<<endl;
exit(1);
}
for(int a=1;a<=num;a++)
{
if(num%a==0)
{
count++;
}
}
if(count==2)
{
cout<<num<<" is a Prime Number. \n";
}
else
{
cout<<num<<" is Composit Number. \n";
}
return 0;
}
No comments:
Post a Comment