In this program, we will check the number entered by user is Positive, Negative or Zero. We have used if statement to check a condition. If number is less than 0 then it is negative number, if it is greater than 0 then that is positive number otherwise it is zero.
#include<stdio.h>
#include<conio.h>
void main()
{
int no;
clrscr();
printf("Enter a number: ");
scanf("%d", &no);
if(no>0)
{
printf("Number %d is positive",no);
}
else if(no<0)
{
printf("Number %d is negative",no);
}
else
{
printf("Number is zero");
}
getch();
}
Enter a number: 5
Number 5 is positive
Enter a number: -21
Number -21 is negative
Enter a number: -0
Number is zero