Module 3: COBOL Program structure
COBOL Word
- A COBOL word can be made using the following characters:-
- 0 – 9
- A – Z (a – z)
- – (Hyphen)
- Created word must be adhered to the following rules:-
- A word cannot begin or end with hyphen
- A word can consist of maximum 30 characters
- At least one character must be letter. Some compilers also make it mandatory to specify first character as letter
- Except hyphen(-) no special characters are allowed
- Examples:-
Valid words Invalid words and reason EMP-NAME -NAME (Invalid since it starts with Hyphen) NEW-TIME EMP LOCATION (Invalid as it contains space between EMP and Location) EMP-DATE30 8-9-10 (Invalid as no letter) - There are two types of words in COBOL :- User-defined words or Reserved words
- The reserved words also called as pre-defined words. It used in COBOL statements and entries for specific requirements
- Some reserved words are: - ADD, SUBTRACT, MULTIPLY, DIVIDE, ACCEPT, IF, EVALUATE, PERFORM etc.
- A complete list of reserved words can be referred in manual supplied with the compiler