C program to check whether a number is positive, negative or zero


In this article, you will learn the concept of c program to check positive negative number i.e. whether the number entered by the user is positive, negative or zero.

Positive number: If the number is greater than zero. i.e. num > 0

Negative number: If the number is less than zero i.e. num < 0

Please go through following articles of C programming to understand the logic of the program.

Simple C program to check if a number is positive, negative or zero

#include <stdio.h>

int main()
{
   float num;

   printf("Enter a number: ");
   scanf("%f", &num);

   if (num < 0.0)
      printf("You entered a negative number.");
   else if (num > 0.0)
      printf("You entered a positive number.");
   else
      printf("You entered zero.");

   return 0;
}


Output: Positive number
c program to check positive negative number

Output: Negative number
c program to check negative number