#include <iostream>
using namespace std;
class prime
{
    int a,b=0;
    public:
    void get();
    void check();
};
void prime::get()
{
    cout<<"Enter a number:"<<endl;
    cin>>a;
}
void prime::check()
{
    for(int i=1;i<=a;i++)
    {
        if(a%i==0)
        {
            b=b+1;
        }
    }
if(b==2)
cout<<a<<" is a Prime number"<<endl;
else
cout<<a<<" is not a Prime number"<<endl;
}
int main()
{
    prime n;
    cout<<"CHECKING PRIME OR NOT :"<<endl;
    n.get();
    n.check();
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: