Character Numbers

This is a warmup exercise. It is not compulsory, and may be completed individually or with your lab partner.

In C, characters (letters, numbers, and symbols) are stored as numbers. There are 128 characters stored as 0-127. The first 0-31 characters are control characters, which don’t print anything. Similarly, 127 is the delete character. Create a file called characterNumbers.c and write a program to print out the decimal and hexademical value of each non-control character (characters 32-126 inclusive), in order, with each line formatted like:

065 0x41 A

Expected Output

032 0x20  
033 0x21 !
034 0x22 "
035 0x23 #
036 0x24 $
037 0x25 %
038 0x26 &
039 0x27 '
040 0x28 (
041 0x29 )
042 0x2a *
043 0x2b +
044 0x2c ,
045 0x2d -
046 0x2e .
047 0x2f /
048 0x30 0
049 0x31 1
050 0x32 2
051 0x33 3
052 0x34 4
053 0x35 5
054 0x36 6
055 0x37 7
056 0x38 8
057 0x39 9
058 0x3a :
059 0x3b ;
060 0x3c <
061 0x3d =
062 0x3e >
063 0x3f ?
064 0x40 @
065 0x41 A
066 0x42 B
067 0x43 C
068 0x44 D
069 0x45 E
070 0x46 F
071 0x47 G
072 0x48 H
073 0x49 I
074 0x4a J
075 0x4b K
076 0x4c L
077 0x4d M
078 0x4e N
079 0x4f O
080 0x50 P
081 0x51 Q
082 0x52 R
083 0x53 S
084 0x54 T
085 0x55 U
086 0x56 V
087 0x57 W
088 0x58 X
089 0x59 Y
090 0x5a Z
091 0x5b [
092 0x5c \
093 0x5d ]
094 0x5e ^
095 0x5f _
096 0x60 `
097 0x61 a
098 0x62 b
099 0x63 c
100 0x64 d
101 0x65 e
102 0x66 f
103 0x67 g
104 0x68 h
105 0x69 i
106 0x6a j
107 0x6b k
108 0x6c l
109 0x6d m
110 0x6e n
111 0x6f o
112 0x70 p
113 0x71 q
114 0x72 r
115 0x73 s
116 0x74 t
117 0x75 u
118 0x76 v
119 0x77 w
120 0x78 x
121 0x79 y
122 0x7a z
123 0x7b {
124 0x7c |
125 0x7d }
126 0x7e ~

To run some simple automated tests:

$ 1511 autotest characterNumbers

To run Styl-o-matic:

$ 1511 stylomatic characterNumbers.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk05_characterNumbers

Or, if you are working from home, upload the relevant file(s) to the wk05_characterNumbers activity on Give Online.