// PRIME Number Checking Program Using Class 
 
 
#include <iostream>
using namespace std;
class prime
{
    int n,i,c=0;
    public:
    void getdata();
    void check();
};
void prime::getdata()
{
    cout<<"\n PRIME  Number Checking Program;"<<endl;
    cout<<"\nEnter a Number : ";
    cin>>n;
    cout<<n<<endl;
}
void prime::check()
{
    if(n==0 || n==1)
    {
        cout<<n<<", is Neither Prime Nor Composite Number."<<endl;
        
    }    
    else
    {
        for(i=1;i<=n;i++)
        {
            if(n%i==0)
            {
               c++;
            }
        }    
        if(c==2)     
            cout<<n<<", is a PRIME Number."<<endl;
        else
            cout<<n<<", is NOT a PRIME Number."<<endl;
    }
}
int main()
{
    prime n;
    n.getdata();
    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: