Write a C program to check positive, negative or zero. C program to input any number from user and check whether the given number is positive, negative or zero. How to check negative, positive or zero using if else in C program. Logic to check negative, positive or zero in C program.

**Example**

**Input**

Input number: 23

**Output**

23 is positive

## Required knowledge

Basic programming, Basic mathematics, Use of relational operator, If else

## Logic to check positive, negative or zero

Logic of this program is simple if you know basic maths. Let us have a quick look about number properties.

- A number is said to be negative if it is less than 0 i.e. n < 0.
- A number is said to be positive if it is greater than 0 i.e. n > 0.

Below is the step by step descriptive logic to check positive, negative or zero.

- Input a number from user in some variable say num.
- Check if num < 0. If the condition is
`true`

, then the number is negative. - Check if num > 0. If the condition is
`true`

, then number is positive. - If the given number is neither positive nor negative. Then the number is zero.

Let us code solution of the program.

## Program to check positive, negative or zero

```
/**
* C program to check positive negative or zero
*/
#include <stdio.h>
int main()
{
int num;
/* Input number from user */
printf("Enter any number: ");
scanf("%d", &num);
if(num > 0)
{
printf("Number is POSITIVE");
}
else if(num < 0)
{
printf("Number is NEGATIVE");
}
else
{
printf("Number is ZERO");
}
return 0;
}
```

Output

Enter any number: 10 Number is POSITIVE

Happy coding 😉

### Recommended posts

- If else programming exercise index.
- C program to find maximum between three numbers.
- C program to check whether the number is even or odd.
- C program to check whether a character is alphabet or not.
- C program to check whether an alphabet is vowel or consonant.
- C program to check whether a character is alphabet, digit or special character.

<pre><code> ----Your Source Code---- </code></pre>