Aspire Faculty ID #13648 · Topic: JAMIA MILLIA ISLAMIA MCA 2023 · Just now
JAMIA MILLIA ISLAMIA MCA 2023

What will be output of following statements? int n1 = 3, n2 = 6, a; printf("(n1 ^ n2) + (a ^ a) = %d", (n1 ^ n2) + (a ^ a));

Solution

Solution: Operator `^` is **bitwise XOR**. $n1 = 3 \Rightarrow 011_2$ $n2 = 6 \Rightarrow 110_2$ $n1 \oplus n2 = 101_2 = 5$ Variable `a` is declared but **not initialized**. Using an uninitialized variable in expression `(a ^ a)` causes **undefined behavior**. Hence, the program compiles but produces a **run-time error or unpredictable result**.

Previous 10 Questions — JAMIA MILLIA ISLAMIA MCA 2023

Nearest first

Next 10 Questions — JAMIA MILLIA ISLAMIA MCA 2023

Ascending by ID
Ask Your Question or Put Your Review.

loading...