Review Questions

I l @ ve RuBoard

Review Questions

  1. Convert the following decimal values to binary:

    1. 3

    2. 13

    3. 59

    4. 119

  2. Convert the following binary values to decimal, octal, and hexadecimal:

    1. 00010101

    2. 01010101

    3. 01001100

    4. 10011101

  3. Evaluate the following expressions; assume each value is 8 bits:

    1. ~3

    2. 3 & 6

    3. 3 6

    4. 1 6

    5. 3 ^ 6

    6. 7 « 1

    7. 7 « 2

  4. Evaluate the following expressions; assume each value is 8 bits:

    1. ~0

    2. !0

    3. 2 & 4

    4. 2 & 4

    5. 2 4

    6. 2 4

    7. 5 « 3

  5. Because the ASCII code uses only the final 7 bits, sometimes it is desirable to mask off the other bits. What's the appropriate mask in binary? In decimal? In octal? In hexadecimal?

  6. In Listing 15.2, you can replace

     while (bits-- > 0)     {         mask = bitval;         bitval = 1;     } 

    with

     while (bits-- > 0)    {         mask += bitval;         bitval *= 2;    } 

    and the program still works. Does this mean the operation *=2 is equivalent to «= 1 ? What about = and += ?

    1. The Tinkerbell computer has a hardware byte that can be read into a program. This byte contains the following information:

      Bit(s) Meaning
      0 “1 Number of 1.4MB floppy drives
      2 Not used
      3 “4 Number of CD-ROM drives
      5 Not used
      6 “7 Number of hard drives

      Like the IBM PC, the Tinkerbell fills in structure bit fields from right to left. Create a bit-field template suitable for holding the information.

    2. The Klinkerbell, a near Tinkerbell clone, fills in structures from left to right. Create the corresponding bit-field template for the Klinkerbell.

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net