# ASCII

Document Sample

```					                                           ASCII

ASCII stands for American Standard Code for Information Interchange. Computers can only
understand numbers, so an ASCII code is the numerical representation of a character such
as 'a' or '@' or an action of some sort. ASCII was developed a long time ago and now the
non-printing characters are rarely used for their original purpose.

ASCII, pronounced "ask-key", is the common code for microcomputer equipment. The
standard ASCII character set consists of 128 decimal numbers ranging from zero through 127
assigned to letters, numbers, punctuation marks, and the most common special characters.
The Extended ASCII Character Set also consists of 128 decimal numbers and ranges from
128 through 255 representing additional special, mathematical, graphic, and foreign
characters.

The computer must use a binary number for each of the characters so it is able to understand
them.

Here is the ASCII table.

1
Using ASCII in Pascal

In Pascal there are various tools available to the programmer for manipulating ASCII values,
these are shown below.

Characters are stored according to a numbered sequence, whereby A has a value of 64
decimal, B a value of 65 etc. Several functions which manipulate characters follow.

CHR
The chr or character position function returns the character associated with the ASCII value

chr( 65 )        will return the character             A

ORD
The ord or ordinal function returns the ASCII value of a requested character. In essence, it
works backwards to the chr function. Ordinal data types are those which have a predefined,
known set of values.
Each value which follows in the set is one greater than the previous. Characters and integers
are thus ordinal data types.

ord( 'C' )       will return the value            67

SUCC
The successor function determines the next value or symbol in the set, thus

succ( 'd' )       will return       e

PRED
The predecessor function determines the previous value or symbol in the set, thus

pred( 'd' )       will return       c

2
Exercises

Here are some exercises to apply these Pascal Functions.

Task 1 – Write a program that uses a FOR..TO..DO loop to write out all the ASCII codes from
32 (space) to 127. The output should be the ASCII code (number) followed by the character it
represents.

Task 2 – Write a program to convert the character the user enters into its ASCII Code and
display it to the user.

3

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 18 posted: 10/20/2011 language: English pages: 3