Home >>c programs >c program to check positive or negative

c program to check positive or negative

Check Given number is positive or negative

If the input number is greater than 0, then the given number is positive, else it is a negative number. If the number is equal to 0, then the given number is equal to zero.

Let's take an example :

#include <stdio.h>
int main()
{
    int num=11;
    if(num>=0)
    {
    printf("Given Number is Positive number");    
    }
    else
    {
    printf("Given Number is negative Number");    
    }    
}
Output :Given Number is Positive number

Number Inputted By user

#include<stdio.h>    
int main()
{    
int num=0;    
printf("Please enter Your  number:");  
scanf("%d",&num); 
if(num>=0)
{
printf("Given Number is Positive num");    
}
else
{
    printf("Given Number is negative num");
}
return 0;  
}    
Output :
Please enter Your number:10
Given Number is Positive num
Output :
Please enter Your number:-10
Given Number is negative num

No Sidebar ads