The class condition determines whether or not the value of an operand is numeric or alphabetic.
An operand is numeric if it contains only the digits 0 to 9 with or without an operational sign.
An operand is alphabetic if it contains only the letters A to Z and space.
General form:
Example program:
IDENTIFICATION DIVISION.
PROGRAM-ID. CLASS.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 A PIC X(10).
PROCEDURE DIVISION.
PARA-1.
DISPLAY “ENTER ANY VALUE”
ACCEPT A.
PARA-2.
IF A IS NUMERIC
DISPLAY “THE GIVEN VALUE IS NUMERIC”.
IF A IS NOT ALPHABETIC
DISPLAY “THE GIVEN VALUE IS NOT ALPHABETIC”.
STOP RUN.
No comments:
Post a Comment