A Program to Check a Number is Positive or Negative
In this example, we are giving a program which is useful to check whether a number given by the user is positive or negative or zero.
Program to check Positive or Negative or Zero:
#include <stdio.h>int main(){double number;printf("Enter a number: ");scanf("%lf", &number);// true if the given number is less than 0if (number < 0.0)printf("It is a negative number.");// true if the given number is greater than 0else if ( number > 0.0)printf("It is a positive number.");// if both the test expression is falseelseprintf("It is 0");return 0;}
Output:
Enter a number: -9 It is a negative number.