Display Computation in COBOL
DISPLAY is the most common form of internal data representation. DISPLAY stores in decimal form. Each character of the data will represent one byte of storage. If there is no usage clause for data items, then by default it will come under DISPLAY.
DISPLAY can be used for all types namely Numeric data types, Alphabetic data types, and Alpha-Numeric data types.
- Numeric: Represents all types of numerical variables and program values or results/outputs.
- Alphabetic: Represents String/texts, and special characters to explain or simplify the program to make it understandable to all.
Example Of Alphabetic Representation:
DISPLAY "ADDITION RESULTS: "
Example Of Numeric Representation:
Example Of Alpha-Numeric Representation:
DISPLAY "RESULTS OF " WS-VAR1 "AND" WS-VAR2 "IS" WS-RESULT
In this program, we are taking the two variables for all operations like addition, subtraction, multiplication, and division. Then we are displaying the proper heading using the DISPLAY keyword and also display the numerical results of the operation. We also tried to maintain proper code formatting using DISPLAY which helps to provide output in an understandable format.