< previous page
page_585
next page >
Page 585
c. y = 17;
d. count++
3. Rewrite each statement as described.
a. Using the
+=
operator, rewrite the statement
sumOfSquares = sumOfSquares + x * x;
b. Using the decrement operator, rewrite the statement
count = count - 1;
c. Using a single assignment statement that uses the
?:
operator, rewrite the statement
if (n > 8)
k = 32;
else
k = 15 * n;
4. What is printed by each of the following program fragments? (In both cases,
ch
is of type
char
.)
a. for (ch = d; ch
g; ch++)
cout < ch;
b. ch = F;
cout < ch < < int(ch); // Assume ASCII
5. What is printed by the following output statement?
cout < Notice that\nthe character \\ is a backslash.\n;
6. If a system supports 10 digits of precision for floating point numbers, what are the results of the following computations?
a. 1.4E+12 + 100.0
b. 4.2E-8+100.0
c. 3.2E-5 + 3.2E+5
7. Define the following terms:
mantissa
significant digits
exponent
overflow
representational error
8. Given the type declaration
enum Agents {SMITH, JONES, GRANT, WHITE};
does the expression
JONES > GRANT
have the value TRUE or FALSE?
9. Given the following declarations,
< previous page
page_585
next page >