Summary -

In this topic, we have explained Character set with detailed examples.

  • Generally, the character is the basic unit of any programming language, and the set of valid characters creates the character-set.
  • 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 COBOL language has its own set of valid characters (78) like other programming languages.

The list of basic COBOL character sets are –

CharacterMeaningUsage
Space Punctuation character
+ Plus sign Arithmetic operator
Editing character
- Minus sign or hyphen Arithmetic operator
Editing character
Continuation character
COBOL word element
* Asterisk Arithmetic operator
Editing character
Comment character
/ Forward slash or solidus Arithmetic operator
Editing character
Continuation character
= Equal sign Punctuation character
Relation character
$ Currency sign Editing character
, Comma Editing character
Punctuation character
; Semicolon Punctuation character
. Decimal point or period Editing character
Punctuation character
" Quotation mark Punctuation character
' Apostrophe Punctuation character
( Left parenthesis Punctuation character
) Right parenthesis Punctuation character
> Greater than Relational character
< Less than Relational character
: Colon 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

For Example -

CharacterUsage & Example
Space Delimiter character
01 WS-A   PIC X(10).
Space used as a delimiter.
+ Arithmetic operator
COMPUTE WS-A = WS-B + WS-C.
+ used as a arithmetic operator.
Editing character.
01 WS-A   PIC +9(3).
+ used as a editing character.
- Arithmetic operator
COMPUTE WS-A = WS-B - WS-C.
- used as a arithmetic operator.
Editing character.
01 WS-A   PIC -9(3).
- used as a editing character.
Continuation character.
----+----1----+----2----+----3----+
***********************************
       01 WS-VAR  PIC X(27) VALUE 
      -     'THIS MULTI-LINE TEXT'. 
- used as a continuation character.
COBOL word element
01 WS-A   PIC 9(3).
- used as a word element.
* Arithmetic operator
COMPUTE WS-A = WS-B * WS-C.
* used as a arithmetic operator.
Editing character.
01 WS-A   PIC **9.
* used as a editing character.
Comment character.
----+----1----+----2----+----3
******************************
      * THIS IS COMMENT LINE. 
* used as a comment character.
/ Arithmetic operator
COMPUTE WS-A = WS-B / WS-C.
/ used as a arithmetic operator.
Editing character.
01 WS-DATE   PIC 99/99/99.
/ used as a editing character.
Continuation character.
----+----1----+----2----+----3----+
***********************************
      /01 WS-VAR  PIC X(27) VALUE 
      /     'THIS MULTI-LINE TEXT'. 
* used as a Continuation character.
= Delimiter character
COMPUTE WS-A = WS-B / WS-C.
= used as a Delimiter character.
Relation character
IF WS-A = 10
= used as a Relation character.
$ Editing character
01 WS-DATE   PIC $$99.
$ used as a Editing character.
, Editing character
01 WS-DATE   PIC 99,999.
, used as a Editing character.
Punctuation character
MOVE 10 TO WS-A, WS-B.
, used as a Punctuation character.
; Punctuation character
. Editing character
01 WS-DATE   PIC $$99.
$ used as a Editing character.
" Punctuation character
01 WS-VAR   PIC X(5) VALUE "HELLO".
" used as a Punctuation character.
' Punctuation character
01 WS-VAR   PIC X(5) VALUE 'HELLO'.
' used as a Punctuation character.
( Punctuation character
 IF (WS-A = 10) AND (WS-B = 5)
( used as a Punctuation character.
) Punctuation character
 IF (WS-A = 10) AND (WS-B = 5)
) used as a Punctuation character.
Relational character
 IF WS-A > 10
> used as a Relational character.
Relational character
 IF WS-A < 10
< used as a Relational character.
: Relational character
 MOVE WS-VAR(1:10) TO WS-VAR1.
: used as a Relational character.
_ User-defined word element
 01 WS_VAR PIC X(10).
_ used as a User-defined word element.
Note! Read this topic once again after the Divisions and variable declarations topics reading is completed. Then you will get a clear understanding.