Input Output Statements Interview Questions


ACCEPT Statement -

What is the function of Accept Verb?

It receives the data from external sources like JCL or the system runtime environment during the program execution.

What are the different ways to receive the input to the program using ACCEPT?

It has two different formats and those are -

  • Receiving input from JCL
  • Receiving system date-related information

How the data received from JCL?

ACCEPT statement without FROM phrasse used to accept the data from JCL.

Specify the rules to code ACCEPT statement?

  • The default input device is SYSIN of Run JCL.
  • One line in the SYSIN DD statement equals the one ACCEPT statement in the COBOL program.
  • The order of data in SYSIN DD should match the order of ACCEPT statements in the COBOL program.

How to receive the current system date in COBOL program?

Using ACCEPT...FROM DATE

How to receive the current system time in COBOL program?

Using ACCEPT...FROM TIME

How do we find current date from the system within a century?

Using ACCEPT...FROM DATE YYYYMMDD

DISPLAY Statement -

What is the significance in DISPLAY statement?

DISPLAY statement prints the variable contents to the output device, from left to right. It is mainly used to -

  • Debug the program when no tools are available.
  • To see the values of the variable at runtime.

What is the usage of WITH NO ADVANCING in DISPLAY statement?

If coded, the cursor does not move to a new line after displaying the content.

How will you display COMP-3 in COBOL?

Once the COMP-3 variable is displayed, use HEX ON to see the actual value in the variable.

What are the two subcategories used in COBOL for reformatting data and displaying values on the screen?

Normal DISPLAY (DISPLAY WITH ADVANCING), DISPLAY WITH NO ADVANCING

Frequently Asked Questions -

What function does the verb ACCEPT serve?
What is the use of the ACCEPT statement in COBOL, and what are the possible options for input data validation?

How can the current date within a century be found in the system?
In a system containing centuries, how to get the present date?

How do you use the DISPLAY statement in COBOL, and what are the different formatting and alignment options available?

How do you use the ACCEPT FROM and DISPLAY TO statements in COBOL, and what are the different options available for input and output redirection?