In this topic, we have explained Character sets with detailed examples.
The character is the fundamental and essential unit of any programming language. The set of valid characters creates the character-set for any programming language that contains the alphabets(A-Z/a-z), digits(0-9), and special characters.
Similarly, the character is a basic and essential unit for the COBOL. COBOL language has its own set of the character-set like other programming languages.
Individual characters are joined to form character-strings, text words and separators in COBOL language.
Character-strings and separators are again used to form words, literals, phrases, clauses, statements, and sentences.
Below is the list of basic COBOL character set –
|+||Plus sign||Arithmetic operator|
|-||Minus sign or hyphen||Arithmetic operator|
COBOL word element
|/||Forward slash or solidus||Arithmetic operator|
|=||Equal sign||Punctuation character|
|$||Currency sign||Editing character|
|.||Decimal point or period||Editing character|
|"||Quotation mark||Punctuation character|
|(||Left parenthesis||Punctuation character|
|)||Right parenthesis||Punctuation character|
|>||Greater than||Relational character|
|<||Less than||Relational character|
|_||Underscore||User-defined word element|
|A - Z||Alphabet (uppercase)||Alphabetic characters|
|a - z||Alphabet (lowercase)||Alphabetic characters|
|0 - 9||Numeric characters||Numeric characters|
COBOL character-set is basic to form any words, literals, phrases, clauses, statements, and sentences. Below examples shows how they are formed -
WS-VAR VAR PARA-ADD PARA-SUBTRACT
MOVE IF PERFORM
"HELLO WORLD" "123" 123 9
REDEFINES PICTURE VALUE
WS-VAR1 WS-VAR2 WS-VAR3
IDENTIFICATION DIVISION. DATA DIVISION. WORKING-STORAGE-SECTION. MOVE 10 TO WS-VAR1.
MOVE 10 to WS-VAR1 PERFORM 10 TIMES.