**Problem:-**Write A C++ Program To Check Number Is Positive Or Negative. The number should be Entered Through the User Then the program Prints the Output.

**Logic:-**As we know that if a number is greater than 0 ( Zero ) Then the number is positive and if a number is Less than 0 ( Zero ) then the number is Negative and if else number is equal to zero then an entered number is Zero or equal to zero. Below is an explanation of the problem with an example. For this type of problem, there may be a maximum of 3 cases, all cases are given below.

**Case 1:-**Either number is greater than zero (Number is Positive).

**Case 2:-**Either number is less than zero (Number is Negative).

**Case 3:-**or number is equal to zero (Number is Equal to Zero).

**Example:-**

**Case 1:-**If a number is greater than zero the number is positive let's take an example to assume the number is 20 then compare the number 20 to zero definitely number is greater than zero so the program will print "Entered number is the Positive number".

int a; // 'a' is a number entered by the user.

if(a>0)

{

cout<<"Number Is Positive:\n";

}

**Case 2:-**If a number is less than zero the number is negative let's take an example to assume the number is -20 then compare the number -20 to zero definitely number is less than zero so the program will print "Entered number is the Negative number".

int a; // 'a' is a number entered by the user.

if(a<0)

{

cout<<"Number Is Negative:\n";

}

**Case 3:-**If a number is equal to zero the number is Zero let's take an example to assume the number is 0 (Zero) and then compare the number 0 (Zero) to Zero definitely number is equal to zero so the program will print "Entered number is Zero".

int a; // 'a' is a number entered by the user.

if(a==0)

{

cout<<"Entered Number Is Zero:\n";

}

**See Also:-**C Program To Check Number Is Positive Or Negative

**Solution:-**

#include<iostream>

using namespace std;

int main()

{

int a;

cout<<"Enter The Number You Want To Check: \n";

cin>>a;

if(a<0)

{

cout<<"Number Is Negative:\n";

}

else if(a>0)

{

cout<<"Number Is Possitive:\n";

}

else

{

cout<<"You Enter Zero :\n";

}

return 0;

}

**See Also:-**Java Program to Find Number Is Positive or Negative

**Output:-**

**You May Also Like:-**

## 0 Comments: