1. ## logical operation

Hello

logical operation between x and y give z

Code:
X Y Z
0 0 0
0 1 1
1 0 1
1 1 1
there are three column R1, R2, R3
if R1 is 1, R2 should be 1
if R1 is 0 , R2 will be unchanged

How to write c program for above logic operation ?

OR Logic
Code:
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1
AND Logic

Code:
0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1

2. Originally Posted by Parth12
there are three column R1, R2, R3
if R1 is 1, R2 should be 1
if R1 is 0 , R2 will be unchanged
So what's the point of R3? And what does this have to do with x, y and z?

3. Originally Posted by laserlight
So what's the point of R3? And what does this have to do with x, y and z?
sorry I have updated previous question because R1, R2, R3 create confuse so Now I am just using X, Y and Z

assume X is status of flag, Y is status of bit and z show the change of Y when flag enable

X flag can be enable and disable and Y is bit

If X flag is disable, bit Y will not change but flag is set, bit Y should be high and Z show the change of y

4. Originally Posted by Parth12
If X flag is disable, bit Y will not change but flag is set, bit Y should be high and Z show the change of y
You had the good idea of drawing a truth table, so let's do that:
Code:
X Y Z
0 0 0
0 1 1
1 0 1
1 1 1
This is the exact truth table you drew in post #1, and indeed it corresponds to what you described. You also drew the truth table for OR, and it corresponds to this exactly. So you have answered your own question: implement an OR.

5. I am confuse with following logic operation, specially with shift operation
What will the final result of X

Code:
X = 0 | 0 << 0X = 0 | 0
X = 0

X = 0 | 1 << 1
X = 0 |
X =

X = 1 | 0 << 1
X = 1 |
X =

X = 1 | 1 << 1
X = 0
X =