In this article, you will learn the concept of c program to check positive negative number i.e. whether the number entered by the user is positive, negative or zero.
Positive number: If the number is greater than zero. i.e. num > 0
Negative number: If the number is less than zero i.e. num < 0
Please go through following articles of C programming to understand the logic of the program.
#include <stdio.h>
int main()
{
float num;
printf("Enter a number: ");
scanf("%f", &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 zero.");
return 0;
}
[adsense1]
Output: Positive number
Output: Negative number