ODD OR EVEN

Muthumari_B · updated September 08, 2021 · C++
// Odd or Even Number checking using class 


#include<iostream>
using namespace std;

class num
{
    int a;
public:

    void input()
   {
        cout << "\nEnter the value of a:";
        cin>>a;
        cout<<a<<endl;
    }

    void check()
    {
        if (a % 2 == 0)
    {
            cout << "\nThe given number is Even"<<endl;
       } 
       else 
       {
            cout <<"\nThe given number is Odd"<<endl;
        }
    }
};

int main()
 {

    num b;

    b.input();
    b.check();

    return 0;
}

Comments

Please sign up or log in to contribute to the discussion.