Positive or Negative Number - C++ Program

Q. Write a C++ program to check whether the input number is positive number or negative number.

Answer:

Following program shows that whether the number entered by user is positive number or negative number.

#include<iostream>
using namespace std;
int main()
{
        int num;
        cout<<"Enter Number : ";
        cin>>num;
        if(num>0)
        {
                cout<<"\n Number is Positive \n";
        }
        else if(num<0)
        {
                cout<<"\n Number is Negative \n";
        }
        else
        {
                cout<<"\n Zero \n";
        }
        return 0;
}


Output:

positive negative