C Program to check if a Number Is Positive Or Negative

C program to check 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.



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: ");
   if (n== 0)
      printf("The number is Zero");
   else if(n>0)
      printf("The number is Positive");
      printf("The number is Negative");


Enter a number: 23
The number is Positive


2 comments on “C Program to check if a Number Is Positive Or Negative”