< previous page page_585 next page >

Page 585
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. y = 17;
d. count++
3. Rewrite each statement as described.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. Using the += operator, rewrite the statement
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
sumOfSquares = sumOfSquares + x * x;
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. Using the decrement operator, rewrite the statement
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
count = count - 1;
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. Using a single assignment statement that uses the ?: operator, rewrite the statement
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
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.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
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?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
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?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
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
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
enum Agents {SMITH, JONES, GRANT, WHITE};
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
does the expression JONES > GRANT have the value TRUE or FALSE?
9. Given the following declarations,

 
< previous page page_585 next page >