List and Explain COBOL Reserved Words
A COBOL word can be formed using the following characters:
[c]0-9
A-Z (a-z)
– (hyphen)
[/c]
The following rules must be adhered to in forming COBOL words:
COBOL Reserved Words:
i. A word cannot begin or end with a hyphen.
ii. A word can have a maximum of 30 characters.
iii. One of the characters must be a letter. Some compilers put the additional restrictions that the first character must be a letter.
iv. Except hyphen (-) no special character allowed.
Example:
Valid Word
Invalid Word & Reason
emp-sal -pay ( it starts with a hyphen)
TOTAL MARK (blank space embedded)
There are 2 types of words in COBOL. A COBOL word can be either a user-defined word or a reserved word. The reserved words are used in COBOL statements and entries for specific purposes by the COBOL compiler.
Example:
ADD, SUBTRACT, DIVIDE, MULTIPLY, IF, PERFORM etc.