=[AD]=
Engineering Exams RRB-JE CS (Chemical Supervisor - Research) Technical Abilities 2025 22.04.25 Paper-2 Shift-2 Easy +1 -0.33
What will be the output of the following C code? void main() { int result=1; if (++result >1 ) printf("%d",result+=3); else printf("%d",result+=5); }
Correct Answer: B. 5
Explanation: The provided C code begins with the variable result initialized to 1. The if statement utilizes a prefix increment operator (++result), which increases the value of result to 2 before evaluating the condition. Since 2 is greater than 1, the condition is true, and the code executes the first printf statement. Inside this statement, the compound assignment result+=3 adds 3 to the current value of 2, updating result to 5. Consequently, the program outputs 5.
Click below to open Discussion & Feedback
0 Issues
Please login to comment or Report Issues.
Reported Issues
=[AD]=