EXERCISE

Muthumari_B · updated August 27, 2021 · C++
#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;
}
void num:: check()
{
    if(x>0)
    cout<<"\n The given number is Positive";
    else if(x<0)
    cout<<"\n The given number is Negative";
    else
    cout<<"\n The given number is zero";
}
int main()
{
    num y;
    y.getdata();
    y.check();
    return 0;
}

Comments

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