A Place for Latest Exam wise Questions, Videos, Previous Year Papers, Study Stuff for MCA Examinations - NIMCET
Previous Year Question (PYQs)
3
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**.
Online Test Series, Information About Examination, Syllabus, Notification and More.