#include <stdio.h>
int main()
{
printf("Hello World
");
char str1[5] = "test";
char str2 = NULL;
printf("
result: %s", str1 ? "str is not empty" : "str is empty");
printf("
result: %s", str2 ? "str is not empty" : "str is empty");
return 0;
}
c = (a < b) ? a : b;
#include <iostream>
int main()
{
int value = (1 > 0 ? 12 : 41);
/*
if 1 > 0 then value is 12, else 41
*/
int val2 = (1 > 0 ? (2 > 4 ? 42 : 45) : 41); // nested
}
Condition ? expression-if-true ; expression-if-false
//Here, '?' and ':' are Ternary Operators