COBOL Interview Questions and Answers
Ques 21. Explain the concept of the INDEXED BY clause.
The INDEXED BY clause in COBOL is used to associate an index name with a table or array. It provides a way to reference individual elements efficiently.
Example:
01 EMPLOYEE-TABLE OCCURS 10 TIMES INDEXED BY EMPLOYEE-INDEX.
...
Ques 22. What is the purpose of the SET statement in COBOL?
The SET statement in COBOL is used to assign values to index names, condition names, and other special registers. It is essential for controlling program flow.
Example:
SET EMPLOYEE-INDEX TO 1.
Ques 23. Explain the concept of the PERFORM VARYING statement.
The PERFORM VARYING statement in COBOL is used for iterative processing. It allows a specified set of statements to be repeated while incrementing or decrementing a loop variable.
Example:
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 10
DISPLAY 'Iteration ' I.
END-PERFORM.
Ques 24. How do you handle date and time in COBOL?
COBOL provides the special registers CURRENT-DATE and CURRENT-TIME to handle date and time operations. These registers store system date and time values.
Example:
MOVE FUNCTION CURRENT-DATE TO DATE-FIELD.
Ques 25. Explain the concept of the INITIALIZE verb.
The INITIALIZE verb in COBOL is used to set the initial values for data items. It initializes numeric items to zero and alphanumeric items to spaces.
Example:
01 COUNT PIC 9(3).
INITIALIZE COUNT.
Most helpful rated by users: