VOOZH about

URL: https://www.geeksforgeeks.org/cobol/display-computation-in-cobol/

⇱ Display Computation in COBOL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Display Computation in COBOL

Last Updated : 2 Aug, 2022

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.

Syntax:

   DISPLAY  NUMERIC/ALPHABETIC   

  • 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:

DISPLAY WS-VARIABLE1 

Example Of Alpha-Numeric Representation:

DISPLAY "RESULTS OF " 
WS-VAR1 "AND" WS-VAR2 
 "IS" WS-RESULT

Example:

Output:

👁 Image
 

Explanation: 

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.

Comment
Article Tags:
Article Tags: