Loading...

Check whether a number is Positive or Negative using if-else

Programme:

#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;
}

Output:

Enter a number : 6
You entered a positive number.