31. WAP to check if a given number is zero or non-zero. If non zero, check if given integer is positive or negative using conditional operator.
#include<stdio.h>
void
main()
{
int num;
printf("Enter a number : ");
scanf("%d",&num);
num==0 ? printf("Zero\n") :
num>>31&1 ? printf("Negative\n") :
printf("Positive\n");
}
Comments
Post a Comment