C Program to Check Whether a Number is Positive or Negative
Example #1: Check if a Number is Positive or Negative Using if...else #include <stdio.h> int main () { double number ; printf ( "Enter a number: " ); scanf ( "%lf" , & number ); if ( number <= 0.0 ) { if ( number == 0.0 ) printf ( "You entered 0." ); else printf ( "You entered a negative number." ); } else printf ( "You entered a positive number." ); return 0 ; } You can also solve this problem using nested if else statement. Example #2: Check if a Number is Positive or Negative Using Nested if...else #include <stdio.h> int main () { double number ; printf ( "Enter a number: " ); scanf ( "%lf" , & number ); // true if number is less than 0 if ( number < 0.0 ) printf ( "You entered a negative number." );