Showing posts with label Write a C program to check if a given Number is zero or Positive or Negative Using if...else statement.. Show all posts
Showing posts with label Write a C program to check if a given Number is zero or Positive or Negative Using if...else statement.. Show all posts
Sunday, August 6, 2023

Write a C program to check if a given Number is zero or Positive or Negative Using if...else statement.


 

Write a C program to check if a given Number is zero or Positive or Negative Using if...else statement.


Program :-


#include <stdio.h>

int main()

{

    double number;

    scanf("%lf", &number); 

if (number <= 0.0)

    {

        if (number == 0.0)

            printf("The number is 0.");

        else

            printf("Negative number.");

    }

    else

        printf("Positive number.");

}


InputOutput
Test Case 1
14.05
Positive number.
Test Case 2
-50
Negative number.