Accept one number and find out if its positive or negative number using class
/******************************************************************************
Accept one number and find out if its positive or negative number using class
*******************************************************************************/
#include <iostream>
using namespace std;
class PosNeg{
private:
int num;
public:
void checkPosNeg(int n){
num=n;
if (num>0)
cout<<num<<" is positive.";
else if (num<0)
cout<<num<<" is negative.";
else
cout<<num<<" is zero";
}
};
int main()
{
PosNeg p;
int x;
cout<<"Enter a number: ";
cin>>x;
p.checkPosNeg(x);
return 0;
}
Comments
Leave a comment