Detailed Print – CSKC
Sign In

Search

siteicon
Code Learning#CPP#7593 Back

Building Expressions and Understanding Operators

Source Code

		 

Click to open popup

Run Output

17
-11
1

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.