#include <iostream>
using namespace std;
int c=0;
class prime{
    int n,i;

    public:

        prime(int a)
        {
            n=a;
        }
           

        void calculate();
        void display();

};
void prime::calculate()
{
    for(i=1;i<=n;i++)
    {
        if(n%i==0)
        {
            c++;
        }
    }

}
void prime::display()
{
    if(c==2)
    {
        cout<<"prime number";
    }
    else
    {
        cout<<"not prime number";
    }
}
int main() {
    int x;
    cout<<"enter the number to check";
    cin>>x;
    prime obj(x);
    obj.calculate();
    obj.display();
    return 0;
}

Embed on website

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