In this c program, you will learn about how to pass an integer value and check if it’s positive or negative.
To start with you need to define an integer variable with the name num.
By using scanf we will take integer value with representation %d. With the help of if-else condition, we will check if the number is greater than zero we will print “It is a positive integer” else if the number is less than zero it will print “it is a negative number.”
Below is the code for you to start with your c program. Cheers.
#include <stdio.h>
void main()
{
int num;
printf("Enter a number: \n");
scanf("%d", &num);
if (num > 0)
printf("%d is a positive number \n", num);
else if (num < 0)
printf("%d is a negative number \n", num);
else
printf("0 is neither positive nor negative");
}