Predict the correct choice for the below XOR and OR operation in the program

#include
using namespace std;

int main()
{

int x = 3, y = 5, z = 6;
int a = 2, b = 4, c = 7;

int res1 = c ^ (x ^ y);
int res2 = z ^ (a ^ b);

cout << (res1 | res2); return 0; } [/sourcecode]

(A) 1
(B) 0
(C) Compile error


Answer: (A)

Explanation: C ^ (x ^ y) and z ^ (a ^ b) both are evaluated and the result is stored in res1 and res2 as 1 and 0 and at last OR is performed on them.

Quiz of this Question


  • Last Updated : 19 Nov, 2018

Share your thoughts in the comments