Starting Vocational Training From 1-May-2024 Get Detail


Write a program in C++ to check whether a number is positive, negative or zero. 
Sample Output:
Check whether a number is positive, negative or zero :
-----------------------------------------------------------
Input a number : 8
The entered number is positive.


#include <iostream.h>
int main()
{
    signed long num1 = 0;
    cout << " Check whether a number is positive, negative or zero : ";
    cout << "----------------------------------------------------------- ";  
    cout << " Input a number : ";
    cin >> num1;
    if(num1 > 0)
    {
        cout << " The entered number is positive. ";
    }
    else if(num1 < 0)
    {
        cout << " The entered number is negative. ";
    }
    else
    {
        std::cout << " The number is zero. ";
    }
    return 0;
}