陷阱的警示--逻辑运算符

来源:互联网 发布:英语语法 大总汇 知乎 编辑:程序博客网 时间:2024/05/02 20:40

A sample example of logical operator.

 

int main()
{
 int a =1, b=2;
 if((a == 0)&& (b++))
  printf("11/n");
 printf("b = %d/n", b);
 if((a == 1) || (b++))
  printf("22/n");
 printf("b = %d/n", b);
 
 if((a == 2) || (b++))
  printf("33/n");
 printf("b = %d/n", b);
 
 return 0;
}

 

What do you think this program will output. Pls check the following result...

 

 

-------------------------

b = 2
22
b = 2
33
b = 3

 

 

原创粉丝点击