C++ Program to Check Given Number is Positive or Negative


Question : Write a C++ program to Check Whether Number is Positive or Negative
?

Explain: C++ Question about check input from user then program tells us which given number is Positive or Negative. We will used simple If-else statement for resolving solution. 

Solution:

 /************************************************************ 
     C++ Program for check Positive or Negative Number using if else 
 *************************************************************
***************** By cpplanguage.com *********************/


#include <iostream>
using namespace std;
int main()
{
    int number_a;
    cout << "Enter an integer: ";
// Obtain input Number_a value
    cin >> number_a;
// input number greater than 0 , Output Positive Number
    if ( number_a > 0)
        cout << number_a << " is a positive number."<<endl;
// input number less  than 0 , Output Negative Number
    else if ( number_a > 0)
// other wise number is negative
        cout << number_a << " is a Negative number."<<endl;
//other wise number is zero
else
cout<<"Number is 0"<<endl;
    return 0;
}

Output:

check Positive or Negative Number using if else