Building Expressions and Understanding Operators
Source Code
|
|
Run Output
Code Understanding
This program shows how arithmetic, increment, and logical operations work in C++.
• int x = 2, y = 5; declares two integer variables.
• y++ increases the value of y by 1 after using it.
• int n = x – y + y/x * (x*y++);
→ The expression is solved step by step using operator precedence.
→ Final value of n is 17.
• int n1 = –x – (y + y/x);
→ –x decreases x by 1 before using it.
→ Result is -11.
• b = (n > x && n1 < y) ? true : false;
→ Checks both conditions; if true, b becomes 1 (true).
→ Output is 1.
Created: 1-Mar-2026 15:59 | Updated: 1-Mar-2026 15:59|
