Question
Check if a Number is Positive, Negative or Zero Using Nested Ternary
Solution
β Verified
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
(num > 0) ? printf("Positive\n") : (num < 0) ? printf("Negative\n") : printf("Zero\n");
return 0;
}
Click here to download practice questions on
Ternary Operator