E.balagurusamy oop 6.6 solution
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
class prime
{
int x;
public :
prime(int n)
{
x=n;
}
void display()
{
int c=0;
if(x==0||x==1)cout<<"Not prime\n";
else
{
for(int i=2;i*i<=x;i++)
{
if(x%i==0)
{
c=1;
break;
}
}
if(c)cout<<"Not prime\n";
else cout<<"Prime\n";
}
}
};
int main()
{
int n;
cout<<"Enter a number : ";
cin>>n;
prime p(n);
p.display();
return 0;
}
0 Comments