Problem 15
Suppose \(\mathbf{x}, \mathbf{y},\) and \(\mathbf{z}\) are int variables and \(\mathbf{w}\) and \(\mathbf{t}\) are double variables. What value is assigned to each of these variables after the last statement executes? x = 23; y = 35; x = x + y / 4 - 3; z = x % 3; w = 28 / 3 + 6.5 * 2; t = x / 4.0 + 15 % 4 - 3.5;
Problem 16
Suppose \(\mathbf{x}, \mathbf{y},\) and \(\mathbf{z}\) are int variables and \(\mathbf{x}=2, \mathbf{y}=5,\) and \(\mathbf{z}=6 .\) What is the output of each of the following statements? a. cout << "x = " << x << ", y = " << y << ", z = " << z << endl; b. cout << "x + y = " << x + y << endl; c. cout << "Sum of " << x << " and " << z << " is " << x + z << endl; d. cout << "z / x = " << z / x << endl; e. cout << "2 times " << x << " = " << 2 *x << endl;
Problem 17
What is the output of the following statements? Suppose a and b are int
variables, \(c\) is a double variable, and \(a=13, b=5,\) and \(c=17.5\)
a. cout << a + b – c << endl;
b. cout << 15 / 2 + c << endl;
c. cout << a / static_cast
Problem 19
Which of the following are correct \(\mathrm{C}++\) statements? a. cout \(<<\) "Hello there!" \(<<\) endl b. cout \(<<\) "Hello"; \(<<\) " There! \("<<\) endl c. cout \(<<\) "Hello" \(<<\) " There! \("<<\) endl d. cout \(<<\) 'Hello There!' \(<<\) endl
Problem 20
Give meaningful identifiers for the following variables: a. A variable to store the first name of a student. b. A variable to store the discounted price of an item. c. A$variable to store the number of juice bottles. d. A variable to store the number of miles traveled. e. A variable to store the highest test score.
Problem 21
Write C++ statements to do the following: a. Declare int variable num1 and num2. b. Prompt the user to input two numbers. c. Input the first number in num1 and the second number in num2. d. Output num1, num2, and 2 times num1 minus num2. Your output must identify each number and the expression.
Problem 23
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; }
Problem 24
include
Problem 25
What action must be taken before a variable can be used in a program?
Problem 26
c. \( d. ! e. None of these. # Preprocessor directives begin with which of the following symbols: a. * b. # c. \) d. ! e. None of these.