NUMBER REPRESENTATION EXERCISES



 1. Convert 7654 from octal to hexadecimal.

 2. Convert 7654 from octal to decimal.

 3. Convert 7654 from decimal to octal.

 4. Convert 7654 from decimal to binary.

 5. Write a program that reads a decimal integer and prints out its 
    value in octal.

 6. Write a program that reads an octal integer and prints out its 
    value in decimal.

 7. Write a program that reads in two floats and prints out their
    ratio, to two decimal places.

 8. Write a program that reads in two doubles and prints out their
    ratio, to two decimal places.

 9. Write a program that reads in two integers and prints out their
    ratio, to two decimal places.

10. Write a program that reads in a positive integer and prints the
    number of digits in its binary representation. For example, the
    binary representation of the decimal integer 7654 is 1110111100110,
    so your program should print 13.

11. Try to figure out what the following program will print.  Type it in,
    compile it, and check.

       #include <stdio.h>
       int main(void) {
          double x = 0.0;
          x = x + 0.1;
          x = x + 0.1;
          x = x + 0.1;
          if (x == 0.3)
             printf("x == 0.3\n");
          else
             printf("x != 0.3\n");
          return 0;
       }