IGDTUW 2026 Computer PYQ — What is the output of the following C program? #include <stdio.h>… | Mathem Solvex | Mathem Solvex
Tip:A–D to answerE for explanationV for videoS to reveal answer
IGDTUW 2026 — Computer PYQ
IGDTUW | Computer | 2026
What is the output of the following C program?
#include <stdio.h>
int main() {
int a = 10, b = 20, c = 30;
printf("%d", (a & b) ? c : b);
return 0;
}
Choose the correct answer:
A.
10
B.
20
(Correct Answer)
C.
30
D.
0
Correct Answer:
20
Explanation
Step-by-Step Explanation:
Variable Initializations: Three integer variables are initialized with decimal values:
a=10,b=20,c=30
Evaluating the Bitwise AND Operation (a & b): The single ampersand & is the bitwise AND operator. To evaluate a & b, we convert the decimal numbers into their 8-bit binary equivalents:
a=10→000010102
b=20→000101002
Now, we perform the logical AND operation column by column (bit by bit):
000010102 & 000101002000000002(10)(20)(0)
Hence, the expression (a & b) evaluates to:
0
Evaluating the Ternary Operator (Condition ? Expression1 : Expression2): The expression inside printf uses the ternary conditional operator ? ::
Result=(0)?c:b
In C, a condition value of 0 represents false.
If the condition is true (non-zero), the statement returns the first value (c).
If the condition is false (0), the statement returns the second value (b).
Final Output: Since the condition evaluated to 0 (false), the expression selects the value of b, which is:
20
Explanation
Step-by-Step Explanation:
Variable Initializations: Three integer variables are initialized with decimal values:
a=10,b=20,c=30
Evaluating the Bitwise AND Operation (a & b): The single ampersand & is the bitwise AND operator. To evaluate a & b, we convert the decimal numbers into their 8-bit binary equivalents:
a=10→000010102
b=20→000101002
Now, we perform the logical AND operation column by column (bit by bit):
000010102 & 000101002000000002(10)(20)(0)
Hence, the expression (a & b) evaluates to:
0
Evaluating the Ternary Operator (Condition ? Expression1 : Expression2): The expression inside printf uses the ternary conditional operator ? ::
Result=(0)?c:b
In C, a condition value of 0 represents false.
If the condition is true (non-zero), the statement returns the first value (c).
If the condition is false (0), the statement returns the second value (b).
Final Output: Since the condition evaluated to 0 (false), the expression selects the value of b, which is: