Language:EN
Pages: 4
Words: 746
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
have the initial values the variables int

Have the initial values the variables int

Evaluate Expression Assignment Answers

Question:

Q3(A) Evaluate the following expressions with explanation for each one: (5 only)

4- z=--x*y +(++y-5)% ++1;

5- z=(x<--y)&&(x>5);

Evaluate Expression Answer and Explanation

1. `z = ++x - y--;`

- `++x` increments `x` before using it, so `x` becomes 11.

- `x` is currently 11 and `y` is 7.

- `x ^ y` performs a bitwise XOR on 11 and 7:

- Binary of 11: `1011`

- Binary of 7: `0111`

3. `z++ = 2 * ++2 + --x * --2;`

- This expression is syntactically incorrect in C/C++. The post-increment operator `z++` cannot be used as an l-value to assign a value.

- Now, evaluate each part:

- `--x * y`: `10 * 8 = 80`

- Now, evaluate the logical expressions:

- `x < --y`: `11 < 7` is `false`

6. `x <<= 2;`

- This is a bitwise left shift assignment.

- Therefore, `x = 44`.

- Explanation: Left shifting 11 by 2 bits results in 44.

- Binary of 7: `0111`

- After shifting 1 bit to the right: `0011` (which is 3 in decimal)

2. `z = (x ^ y + x & y);` → `z = 15`

3. `z++ = 2 * ++2 + --x * --2;` → Syntax error

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Wahida rehmani

PageId: DOC3B8F65E