Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. For each of the following expressions, assume that a, b, and c are int variab

ID: 639841 • Letter: 1

Question

1.      For each of the following expressions, assume that a, b, and c are int variables and their values are as follows: a = 1, b = 2, c = 3. Each expression is to be treated independently; i.e., for each expression, a, b, and c start out as 1, 2, and 3, respectively, even if a variable's value changed in a previous expression. Evaluate each expression. You must show your work. I need help with these i think the answer are

a)      static_cast<int>(6.9) + (a / 4) * 4

6.9 + 2/4 * 4

6.9 + .5 * 4

6.9 + 2

8.9

b)      4.5 / (a = b = c)

4.5 / 1=1=1

4.5

c)      b && (b > 2)

false

d)      ++b * 3 % 2

3 * 3 % 2

3 * 1

3

e)      c - 2.5 / 10

3 - 2.5 / 10

3 - .25

2.75

Explanation / Answer

a ) ststic_cast<int >(x) will return the integer part of the argument so we will get 6
value of a is 1 so (1/4)*4 will give 1
so
6 + (1/4)*4
6 + 1
7

b)
4.5 / (a = b = c)
Assignment operator is used
so denominator will be 3
4.5/3
1.5

c)b&&(b>2)

b is right shifted by 2
the second b becomes 0
so false

d)multiplication is higher priorty than modiulus operator
So first multiplication then modulus

3 *3 %2
9%2
1

e)c - 2.5/10
3 - .25
2.75