Short-circuit and short-circuit and short circuit or a short circuit or not

First look at the cattle off of a question

By the following statement after the arithmetic and logic operation i and j is ()
int i = 0;
int j = 0;
IF ((++ i> 0) || (++ j> 0))
{
// Print the value of i and j.
}

A i=0;j=0
B i=1;j=1
C i=0;j=1
D i=1;j=0 

The answer is: D

why?

Investigated the use of a short-circuit logic

&& and || are short-circuited and short-circuited or 

&& If the result of the expression is false front, the overall results of a logical expression is false, so that the latter expression, whether true or false can not affect the result of the entire logical expression, so in order to improve code efficiency, the expression that will not be executed

Similarly, if the preceding expression is true, the expression that also need not be calculated

& And | is not short-circuited with and without short-circuiting or

Whatever the case, the front and back of the expressions have to perform

Guess you like

Origin blog.csdn.net/weixin_43224539/article/details/91391351