兰舟千帆
2021-12-08 21:30
采纳率: 84.2%
浏览 8

C语言逻辑运算符操作(大家自行运行如下代码进行思考)

 请大家自行运行如下代码进行思考

//c语言逻辑运算符的相关操作。
#include<stdio.h>
#include<windows.h>
int main()
{
    int a = 3,b =3;
    int d1 = 3^4;//异或按位,转换为二进制进行异或,然后再转换为十进制
    int d2 = 4>>2;//按位右移运算符
    printf("d2 = %d\n",d2);
    printf("d1 = %d\n",d1);
    int c1 =  (a=0)&&(b=3);//短路与
    printf("a = %d,b = %d \n",a,b);
    printf("c1=:%d\n",c1);
    int c2=(a = 1)||(b = 5);//短路或
    printf("a=%d,b=%d\n",a,b);
    printf("c2=%d\n",c2);
    int c3= (a=4)|(b=7);//按位或
    printf("a=%d,b=%d\n",a,b);
    printf("c3=%d\n",c3);
    int c4 =(a=8)&(b=9);//按位与
    printf("a=%d,b=%d\n",a,b);
    printf("c4=%d\n",c4);
    system("pause");


}

相关推荐 更多相似问题