The program outputs 4 because the expression 2 / 1 + 4 / 2 evaluates to 4 using the integer arithmetic rules in C. The division operator / performs integer division when both operands are inte-gers, which means it discards the fractional part of the result. Therefore, 2 / 1 is 2 and 4 / 2 is 2, and their sum is 4. The printf function then prints the value of i as a decimal integer using the %d format specifier.
References = CLA – C Certified Associate Programmer Certification, C Essentials 2 - (Intermediate), C Operators
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit