C Program to check if a Number Is Positive Or Negative
#include <stdio.h>
int main()
{
int num = 23;
//Conditions to check if the number is negative/positive or zero
if (num > 0)
printf("The number is positive");
else if (num < 0)
printf("The number is negative");
else
printf("Zero");
return 0;
} Output:
Insert a number: 23
The number is Positive
#include <stdio.h>
int main()
{
int num = -10;
//Condition to check if num is negative/positive or zero
if (num >= 0)
{
if (num == 0)
printf("The number is 0");
else
printf("The number is Positive");
}
else
printf("The number is Negative");
return 0;
}Output
Insert a number: -10
The number is Negative
#include <stdio.h>
int main()
{
int num = -4;
//Condition to check if the 0, positive or negative
if(num == 0)
printf("Zero");
else
(num > 0) ? printf("Positive"): printf("Negative");
return 0;
}Insert a number: -4
Negative
No comments