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 
    


© DFStermole: 10 Oct 2000