Given \(π=0,π=1,π=β1\) \( x = 0.5, y = 0.0\) What is the output of givenβ¦
2016
GivenΒ \(π=0,π=1,π=β1\)
\( x = 0.5, y = 0.0\)
What is the output of givenΒ \(βCβ\) expression?
x * 3 & & 3 || j | k
- A.
- 1
- B.
0
- C.
1
- D.
2
Attempted by 552 students.
Show answer & explanation
Correct answer: C
Solution: evaluate the arithmetic and then the logical/bitwise operations step by step.
Compute x * 3: 0.5 * 3 = 1.5, which is non-zero (true in a logical context).
Evaluate (x * 3) && 3: both operands are non-zero, so this logical AND yields 1.
Compute j | k: 1 | -1 = -1 (in two's complement, -1 has all bits set, so bitwise OR with 1 stays -1).
Final step: 1 || -1 is a logical OR of two non-zero values, which yields 1.
Therefore the expression evaluates to 1.