NAME
NAME
a. 32 times a plus b
Answer: int a, b;
int result = 32 * a + b;
d. (b² - 4ac) / 2a
Answer: int a, b, c;
e. (a + b) / c * (e * f) - gh
Answer: int a, b, c, g, h;
float e, f;
---
x = 5;
z = 3;
y = x - z;
z = 2 * y + 3;
w = x - 2 * y + z;
z = w - x;
w++;
Answer:
x=5
y=2
z=3
w=9
---
3. Suppose x, y, and z are int variables and w and t are double
variables. What value is assigned to each of these variables after
the last statement executes?
x = 17;
y = 15;
x = x + y / 4;
z = x % 3 + 4;
w = 17 / 3 + 6.5;
t = x / 4.0 + 15 % 4 - 3.5;
Answer:
x = 20
z=6
w = 11.5
t = 4.5
---
a. cout << "x = " << x << ", y = " << y << ", z = " << z << endl;
Answer: x = 2, y = 5, z = 6
b. cout << "x + y = " << x + y << endl;
Answer: x + y = 7
c. cout << "Sum of " << x << " and " << z << " is " << x + z << endl;
Answer: Sum of 2 and 6 is 8
e. cout << "2 times " << x << " = " << 2 *x << endl;
Answer: 2 times 2 = 4
---