Program to test a number for positive, negative or zero value in C

#include <stdio. h>
int main()
{ 
int x;
   printf("Enter the number to test: \n") ;
   scanf("%d",&x) ;
if(x)
  {
     printf(" \nThe input is a non-zero value. \n") ;
     if(x<0)
        printf("The number is negative. \n");
     else
  printf("The number is positive. \n") ;
   }
else
        printf("\nThe number is zero. \n") ;
return 0;
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.