To Check Whether a Number is Positive or Negative in C Program

#include <stdio.h>
void main()
{
    int num;
    printf("Input a number :");
    scanf("%d", &num);
    if (num >= 0)
        printf("%d is a positive number \n", num);
    else
        printf("%d is a negative number \n", num);
}

Output:

Input a number :15
15 is a positive number 
Sharing Is Caring

Leave a Comment