C Program if else : "Conditional Operator Example" with output
#include <stdio.h>
int main() { int num; printf("Enter an integer: "); scanf("%d", &num); // Using the conditional (ternary) operator // Syntax: condition ? expression_if_true : expression_if_false num >= 10 ? printf("Input is greater than or equal to 10\n") : printf("Input is less than 10\n"); return 0; }Enter an integer: 7
Input is less than 10
Enter an integer: 15
Input is greater than or equal to 10
Comments
Post a Comment