Input and Output Using Characters
The input term and output term are straightforward. Sometimes it is complex to use the full stops and quotes, and it is not always suitable. For example, to define a predicate that would read characters in series from the keyboard and count the number of vowels is really tedious. For this kind of problem, a better approach is to input a character at a time. To apply this approach, we have to know the ASCII value of the characters. ASCII (American Standard Code for Information Interchange) value is an integer from 0 to 255.
All non-printing characters and printing characters have their corresponding ASCII value. ASCII value of characters, which is less than or equal to 32 is called as control characters or white space characters.
The following table shows the ASCII values of printable characters and some others.
Number | Character | Description |
---|---|---|
9 | Tab | |
10 | end of record | |
32 | space | |
33 | ! | exclamation mark |
34 | “ | quotation mark |
35 | # | number sign |
36 | $ | dollar sign |
37 | % | percent sign |
38 | & | ampersand |
39 | ‘ | apostrophe |
40 | ( | left parenthesis |
41 | ) | right parenthesis |
42 | * | asterisk |
43 | + | plus sign |
44 | , | comma |
45 | – | hyphen |
46 | . | period |
47 | / | slash |
48 | 0 | 0 digit |
49 | 1 | 1 digit |
50 | 2 | 2 digit |
51 | 3 | 3 digit |
52 | 4 | 4 digit |
53 | 5 | 5 digit |
54 | 6 | 6 digit |
55 | 7 | 7 digit |
56 | 8 | 8 digit |
57 | 9 | 9 digit |
58 | : | colon |
59 | ; | semicolon |
60 | < | less-than |
61 | = | equals-to |
62 | > | greater-than |
63 | ? | question mark |
64 | @ | at sign |
65 | A | uppercase A |
66 | B | uppercase B |
67 | C | uppercase C |
68 | D | uppercase D |
69 | E | uppercase E |
70 | F | uppercase F |
71 | G | uppercase G |
72 | H | uppercase H |
73 | I | uppercase I |
74 | J | uppercase J |
75 | K | uppercase K |
76 | L | uppercase L |
77 | M | uppercase M |
78 | N | uppercase N |
79 | O | uppercase O |
80 | P | uppercase P |
91 | Q | uppercase Q |
82 | R | uppercase R |
83 | S | uppercase S |
84 | T | uppercase T |
85 | U | uppercase U |
86 | V | uppercase V |
87 | W | uppercase W |
88 | X | uppercase X |
89 | Y | uppercase Y |
90 | Z | uppercase Z |
91 | [ | left square bracket |
92 | backslash | |
93 | ] | right square bracket |
94 | ^ | Caret |
95 | _ | underscore |
96 | ` | grave accent |
97 | A | lowercase a |
98 | B | lowercase b |
99 | C | lowercase c |
100 | D | lowercase d |
101 | E | lowercase e |
102 | F | lowercase f |
103 | G | lowercase g |
104 | H | lowercase h |
105 | I | lowercase i |
106 | J | lowercase j |
107 | K | lowercase k |
108 | L | lowercase l |
109 | M | lowercase m |
110 | N | lowercase n |
111 | O | lowercase o |
112 | P | lowercase p |
113 | Q | lowercase q |
114 | R | lowercase r |
115 | S | lowercase s |
116 | T | lowercase t |
117 | U | lowercase u |
118 | V | lowercase v |
119 | W | lowercase w |
120 | X | lowercase x |
121 | Y | lowercase y |
122 | Z | lowercase z |
123 | { | left curly brace |
124 | | | vertical bar |
125 | } | right curly brace |
126 | ~ | tilde |