Download CS240 Programming in C

Transcript
Short-Circuit && (and) and || or
expression

e1 && e2 is the short circuit “and” expression

If e1 is false, e2 is not evaluated.
if(x && (i = y))
// If x is false
// then i=y is never evaluated.

e1 || e2 is the short circuit “or” expression

If e1 is true, then e2 is never evaluated
if (x || (i=y))
// If x is true, then i=y
// is never evaluated.
Related documents