本文介绍了逻辑运算c的预增的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能解释为什么执行后c仍然等于15
Can any one explain why c still equal 15 after execution
int main(void)
{
int t,a=5,b=10,c=15;
t= ++a||++c;
printf("%d %d %d",t,a,c);
}
推荐答案
逻辑或运算符||
是短路运算符.如果左侧求出的是布尔值(即非0),则右侧不会执行.
The logical-or operator ||
is a short-circuit operator. If the left side evaluates to a true boolean value (i.e. not 0), then the right side doesn't execute.
与逻辑和运算符&&
类似,如果左侧为假(即0),则右侧将不执行.
Similarly for the logical-and operator &&
, if the left hand side is false (i.e. 0) the right hand side does not execute.
这篇关于逻辑运算c的预增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!