C Program to Check Whether a Number is Positive, Zero or Negative

Program


#include<stdio.h>
#include<conio.h>

int main()
{
	 int number;
	 clrscr();
	 printf("Enter number: ");
	 scanf("%d", &number);
	
	 if(number==0)
	 {
	  	printf("%d is ZERO.", number);
	 }
	 else if(number>0)
	 {
	  	printf("%d is POSITIVE.", number);
	 }
	 else
	 {
	  	printf("%d is NEGATIVE.", number);
	 }
	 getch();
	 return(0);
}

Output of the above program :

Run 1:
----------
Enter number: 89 ↲
89 is POSITIVE.

Run 2:
----------
Enter number: 0 ↲
0 is ZERO.

Run 3:
----------
Enter number: -17 ↲
-17 is NEGATIVE.

Note: ↲ indicates ENTER is pressed.