Question #23968

1. What does the following code output?

int c = 1;

c += 2 / 3 * c + 7*(c+1);

int c = 1;

c += 2 / 3 * c + 7*(c+1);

Expert's answer

int c = 1;

c += 2 / 3 * c + 7*(c+1);

the answer will be 15:

term 2/3*c = 2/3*1 = 2/3 (round down as integer) = 0

term 7*(c+1) = 7*(1+1) = 14

C += 0 + 14

С = 15

c += 2 / 3 * c + 7*(c+1);

the answer will be 15:

term 2/3*c = 2/3*1 = 2/3 (round down as integer) = 0

term 7*(c+1) = 7*(1+1) = 14

C += 0 + 14

С = 15

Learn more about our help with Assignments: C++

## Comments

## Leave a comment