# C Program to check if a Number Is Positive Or Negative ## Write a C program to check if  number is a Positive or Negative

The following concept will test weather a number is positive or negative. It is done by checking where the number lies on the number line. The following algorithm will help to check this condition.

• If the input number is greater than zero then it is a positive number.
• If the input number is less than zero it is a negative number.
• If the number is zero then it is neither positive nor negative.

Same logic we have followed in the below C program.

## Algorithm

Step 1. Start

Step 2. Insert the number.

Step 3. If the number is Zero then print “The number is Zero”

Step4: If the number is greater than zero, then print, “The number is Positive”

Step 5. Else print, “The number is Negative”

Step 6. Stop

## C Code

```#include <stdio.h>
int main()
{
int n;
printf("Enter a number: ");
scanf("%d",&n);
if (n== 0)
printf("The number is Zero");
else if(n>0)
printf("The number is Positive");
else
printf("The number is Negative");
}```

### Output:

```Enter a number: 23
The number is Positive``` ### 2 comments on “C Program to check if a Number Is Positive Or Negative”

• somesh

in which version of C platform you have typed this code. sir,plzzz tell 0
• PrepInsta

Version is C11 3