Example
Input
Input number: 23
Output
23 is positive
/**
* C program to check positive negative or zero using switch case
*/
#include <stdio.h>
int main()
{
int num;
printf("Enter any number: ");
scanf("%d", &num);
switch (num > 0)
{
// Num is positive
case 1:
printf("%d is positive.", num);
break;
// Num is either negative or zero
case 0:
switch (num < 0)
{
case 1:
printf("%d is negative.", num);
break;
case 0:
printf("%d is zero.", num);
break;
}
break;
}
return 0;
}
/*
Output :
Enter any number: 23
23 is positive.
Enter any number: -22
-22 is negative.
Enter any number: 0
0 is zero.
*/