Description
- Evaluate the following expressions:
- 36 / 5
- 18 − 32 / 6 * 3
- 6 − 8 % 11
- 0 / 5
- 25 − 7 % 3 + 8 / 3
- 0 + 5.0 * 3.0 / 4.0
- Suppose x, y, and z are int variables and x = 2, y = 5, and z = 6. What is the output of each of the following statements?
- cout << “x = ” << x << “, y = ” << y << “, z = ” << z;
- cout << “Sum of ” << x << ” and ” << z << ” is ” << x + z;
- cout << “2 times ” << x << ” = ” << 2 * x;
- The following program has syntax mistakes. Correct them. On each successive line, assume that any preceding error has been corrected.
const char = STAR = ‘*’ const int PRIME = 71; int main {
int count, sum; double x; count = 1; sum = count + PRIME; x := 25.67; newNum = count * ONE + 2; sum + count = sum; x = x + sum * COUNT;
cout << ” count = ” << count << “, sum = ” << sum
<< “, PRIME = ” << Prime << endl;
}
- Suppose a, b, and c are int variables and a = 5 and b = 6. What value is assigned to each variable after each statement executes? If a variable is undefined at a particular statement, report UND (undefined).
| a | b | c | |
| a = (b++) + 3; | |||
| c = 2 * a + (++b); | |||
| b = 2 * (++c) – (a++); |
Self-Review Exercise Module 3 p. 1/1




