Programming Code Center(PCC)
[C]

(PCC)::[C-Program-to-Check-Whether-a-Number-is-Positive-or-Negative]::[c]

File Name : Positive_or_Negative.c

//Check Positive or Negative Using if...else
#include <stdio.h>
int main() {
    double num;
    printf("Enter a number: ");
    scanf("%lf", &num);
    if (num <= 0.0) {
        if (num == 0.0)
            printf("You entered 0.");
        else
            printf("You entered a negative number.");
    } else
        printf("You entered a positive number.");
    return 0;
}


//Check Positive or Negative Using Nested if...else
#include <stdio.h>
int main() {
    double num;
    printf("Enter a number: ");
    scanf("%lf", &num);

    if (num < 0.0)
        printf("You entered a negative number.");
    else if (num > 0.0)
        printf("You entered a positive number.");
    else
        printf("You entered 0.");

    return 0;
}

Output :

Positive_or_Negative.jpg