Back to DFS's C Page


OAC Problem Set I

Loops

  1. You are to write three programs which produce the following outputs. Each program will use one of the three loop structures, for, do-while, and while. This will be done in two stages. The first will count from 0 to 20 in decimal, octal, and hexadecimal. The second will add binary.

      Dec  Hex   Oct
        0    0     0 
        1    1     1 
        2    2     2 
        3    3     3 
        4    4     4 
        5    5     5 
        6    6     6 
        7    7     7 
        8    8    10 
        9    9    11 
       10    A    12 
       11    B    13 
       12    C    14 
       13    D    15 
       14    E    16 
       15    F    17 
       16   10    20 
       17   11    21 
       18   12    22 
       19   13    23 
       20   14    24 
    
      Dec      Bin   Hex   Oct
        0        0     0     0 
        1        1     1     1 
        2       10     2     2 
        3       11     3     3 
        4      100     4     4 
        5      101     5     5 
        6      110     6     6 
        7      111     7     7 
        8     1000     8    10 
        9     1001     9    11 
       10     1010     a    12 
       11     1011     b    13 
       12     1100     c    14 
       13     1101     d    15 
       14     1110     e    16 
       15     1111     f    17 
       16    10000    10    20 
       17    10001    11    21 
       18    10010    12    22 
       19    10011    13    23 
       20    10100    14    24 
    
  2. Create the following ASCII chart.
               ASCII CHART
      0 1 2 3 4 5 6 7 8 9 A B C D E F
    0       0 @ P ` p       ° À Ð à ð
    1     ! 1 A Q a q     ¡ ± Á Ñ á ñ
    2     " 2 B R b r     ¢ ² Â Ò â ò
    3     # 3 C S c s     £ ³ Ã Ó ã ó
    4     $ 4 D T d t     ¤ ´ Ä Ô ä ô
    5     % 5 E U e u     ¥ µ Å Õ å õ
    6     & 6 F V f v     ¦ ¶ Æ Ö æ ö
    7     ' 7 G W g w     § · Ç × ç ÷
    8     ( 8 H X h x     ¨ ¸ È Ø è ø
    9     ) 9 I Y i y     © ¹ É Ù é ù
    A     * : J Z j z     ª º Ê Ú ê ú
    B     + ; K [ k {     « » Ë Û ë û
    C     , < L \ l |     ¬ ¼ Ì Ü ì ü
    D     - = M ] m }     ­ ½ Í Ý í ý
    E     . > N ^ n ~     ® ¾ Î Þ î þ
    F     / ? O _ o       ¯ ¿ Ï ß ï ÿ
    
  3. Write a program which requests two strings and a location in the second. Write a function which inserts the first string into the second at the point specified. The mainline should then print out the resultant string.


© DFStermole: 1 Nov 1998