khuang8493
6/11/2018 - 11:28 PM

Shorthand if else statement in C

A simpler way to express if, else.

int x = (expr) ? 5 : 6;

int opening_time = (day == SUNDAY) ? 12 : 9;

//instead of the more verbose

int opening_time;

if (day == SUNDAY)
    opening_time = 12;
else
    opening_time = 9;