A
COBOL word can be formed using the following characters:
0-9
A-Z (a-z)
- (hyphen)
The
following rules must be adhered in forming COBOL
words:
A word cannot begin or end with a hyphen. A word
can have at the maximum 30 characters. One of the
characters must be a letter. Some compilers put
the additional restrictions that the first character
must be a letter. Except hyphen (-) no special character
allowed.
Examples
Valid Cobol Word :
EMP-SAL
NET-SALARY
TOT-MARK
N100
Invalid Cobol Word :
-PAY (it starts with a hyphen)
TOTAL MARK (blank space embedded)
COMPUTE (Reserved word)
MULTIPLY (Reserved word)
23 (No letter)
There
are 2 types of words in COBOL. A COBOL word can
be either a USER-DEFIND WORD or RESERVED WORD. The
reserved words are used in COBOL statements and
entries for specific purposes by the COBOL compiler.
Some reserved words are given below:
ADD, SUBTRACT, DIVIDE, MULTIPLY, IF, PERFORM etc.
Any attempt by the programmer to declare the reserved
word will be indicated as an error during the compilation
stage of the program.