POSITIVE OR NEGATIVE

Muthumari_B · updated September 08, 2021 · C++
// Positive, Negative or Zero checking using class


#include <iostream>
using namespace std;
class num
{
    int x;
    public:
    void getdata();
    void check();
};
void num::getdata()
{
    cout<<"\n Enter the value of x : ";
    cin>>x;
    cout<<x<<endl;
}
void num:: check()
{
    if(x>0)
    cout<<"\n The given number is Positive"<<endl;
    else if(x<0)
    cout<<"\n The given number is Negative"<<endl;
    else
    cout<<"\nThe given number is zero"<<endl;
}
int main()
{
    num y;
    y.getdata();
    y.check();
    return 0;
}

Comments

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