- int main()
- {
- int x,y,z;
- x=03;y=02;z=01;
- printf(“%d\n”,x|y&z);
- printf(“%d\n”,x|y&~z);
- printf(“%d\n”,x^y&z);
- printf(“%d\n”,x&y&&z);
- x=1;y=-1;
- printf(“%d\n”,!x|x);
- printf(“%d\n”,~x|x);
- printf(“%d\n”,x^x);
- x<<=3; printf(“%d\n”,x);
- y<<=3;printf(“%d\n”,y);
- y>>=3;printf(“%d\n”,y);
- return o;
- }
i m facing problem in this program from starting…………how the negiate operator work…………also in left & right shift operator…………
Execution process from top:
x=03;y=02;z=01;
printf(“%d\n”,x|y&z);//evaluation is: (x | (y&z))
printf(“%d\n”,x|y&~z);//evalusation is: (x | (y & (~z)))
printf(“%d\n”,x^y&z);//evaluation is: (x ^ (y & z))
printf(“%d\n”,x&y&z);//evaluation is: ((x&y)&z)
x=1;y=-1;
printf(“%d\n”,!x|x);//evaluation is: ((!x) | x)
printf(“%d\n”,~x|x);//evaluation is: ((~x) | x)
printf(“%d\n”,x^x);// evaluation of XOR operation
x<<=3; printf("%d\n",x);// initialy x = 01 hence 01<<=3 results to 8
y<<=3; printf("%d\n",y);// initially y = -01 hence -01 <>=3; printf(“%d\n”,y);// initially y = -08 hence 08 >>= 3 results to -1
priority order
& —> ^ —> |
if you find ~ ,then solve it first