Program -
#include<iostream.h>
#include<conio.h>
class abc
{
int n;
public:
abc(int c)
{
n=c;
}
void print();
};
void abc::print()
{
int i;
if(n==1)
{
cout<<"not
prime";
return;
}
for(i=2;i<=n/2;i++)
if(n%i==0)
{
cout<<"not
prime";
return;
}
cout<<"number
is prime";
}
void main()
{
int n;
clrscr();
cout<<"enter
the number:";
cin>>n;
abc a(n);
a.print();
getch();
}
Output -
enter the number:3
number is prime
0 comments:
Post a Comment