9Google AdSense

Checking a number is postive or negative in C using If-Else

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int number;
    //number = 50;

    scanf("%d",&number);

    if(number == 0)
        printf("Given number is %d",number);
    else if(number>0)
        printf("%d is a Positive number",number);
    else
        printf("%d is a Negative number",number);

    return 0;
}

Output:



No comments: