#include <iostream>
#include <conio>
class prime
{
private:
int n,i,res;
public:
int input(int n)
{
for(i=2;i<=n-1;i++)
{
if(n%i==0)
{
return 0;
}}
if(i==n)
return 1;
}
void show()
{
cout<<"Plz enter an integer\t\t";
cin>>n;
res=input(n);
if(res==1)
cout<<n<<"is prime\n";
else
cout<<n<<" is not prime\n";
}
};
void main()
{
prime p;
p.show();
getch();}
#include <conio>
class prime
{
private:
int n,i,res;
public:
int input(int n)
{
for(i=2;i<=n-1;i++)
{
if(n%i==0)
{
return 0;
}}
if(i==n)
return 1;
}
void show()
{
cout<<"Plz enter an integer\t\t";
cin>>n;
res=input(n);
if(res==1)
cout<<n<<"is prime\n";
else
cout<<n<<" is not prime\n";
}
};
void main()
{
prime p;
p.show();
getch();}
0 comments:
Post a Comment