C Program to Check Whether a Number is Positive or Negative



 c program to check whether a number is positive or negative

Learn C - C tutorial - c program to check whether a number is positive or negative - C examples - C programs

C Program to Check Whether a Number is Positive or Negative

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

Sample Code

#include <stdio.h>
int main()
{
    double number=-45;
    printf("number:63 \n");
    if (number <= 0.0)
    {
        if (number == 0.0)
            printf("You entered 0.");
        else
            printf("It's a Negative number.");
    }
    else
        printf("It's a Positive number.");
    return 0;
}

Output

number:-45 
It's a Negative number.


View More Quick Examples


Related Searches to C Program to Check Whether a Number is Positive or Negative