- Very strong in business data processing.
- Handles huge amounts of data efficiently.
- Still used in banking, finance, insurance, government systems.
- Easy to read (English-like).
Category: Interview Questions
-
What are COBOL’s strengths?
-
SEARCH and SEARCH ALL?
- SEARCH → Linear search, works with unsorted tables.
- SEARCH ALL → Binary search, requires sorted table, faster.
-
How does COBOL handle files?
COBOL uses FILE SECTION in DATA DIVISION.
- Files are processed using OPEN, READ, WRITE, CLOSE.
Example:
IDENTIFICATION DIVISION. PROGRAM-ID. FILE-DEMO. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL.
DATA DIVISION. FILE SECTION. FD EMP-FILE. 01 EMP-REC. 05 EMP-ID PIC 9(4). 05 EMP-NAME PIC A(20). WORKING-STORAGE SECTION. 01 WS-EOF PIC X VALUE 'N'. PROCEDURE DIVISION.SELECT EMP-FILE ASSIGN TO 'EMP.DAT' ORGANIZATION IS LINE SEQUENTIAL.
OPEN INPUT EMP-FILE PERFORM UNTIL WS-EOF = 'Y' READ EMP-FILE AT END MOVE 'Y' TO WS-EOF NOT AT END DISPLAY EMP-REC END-READ END-PERFORM CLOSE EMP-FILE STOP RUN.
-
GOBACK, and EXIT PROGRAM?
STOP RUN → Ends the main program & returns control to OS.
GOBACK → Returns control to caller (or OS if no caller).
EXIT PROGRAM → Used in subprograms to return control to calling program.
-
88 level in COBOL?
- Level 88 → Conditional variable, used for readability in conditions.
Example:
01 STATUS-CODE PIC 9(1). 88 SUCCESS VALUE 1. 88 FAILURE VALUE 0. IF SUCCESS DISPLAY "Operation Successful".
-
WORKING STORAGE SECTION and LINKAGE SECTION?
WORKING-STORAGE: Declares variables for the current program.
LINKAGE SECTION: Declares variables that come from another program or JCL (passed parameters).
-
PERFORM and CALL?
- PERFORM → used for executing a paragraph or section within the same program (like a loop or subroutine).
- CALL → used for calling an external program or subprogram.
Example:
PERFORM CALC-PARA. *> internal call CALL 'SUBPROG' USING VAR1. *> external program call
-
What is PIC clause in COBOL?
PIC
stands for Picture Clause → defines the type & size of a variable.
Example:
01 NAME PIC A(10). *> 10 characters (Alphabetic) 01 AGE PIC 9(3). *> 3-digit number 01 SALARY PIC 9(5)V99. *> 5 digits + 2 decimal places
-
COMP and COMP-3?
- COMP (Binary Storage): Data stored in pure binary format. Faster for arithmetic operations.
- COMP-3 (Packed Decimal): Data stored in packed format (2 digits per byte). Saves space, often used in financial apps.
Example:
01 A PIC 9(4) COMP. *> Binary storage 01 B PIC 9(4) COMP-3. *> Packed decimal storage
-
divisions in COBOL program?
COBOL program is divided into 4 divisions:
- IDENTIFICATION DIVISION – program info (name, author).
- ENVIRONMENT DIVISION – environment details (input-output devices).
- DATA DIVISION – data & variables declaration.
- PROCEDURE DIVISION – actual logic/code.
Example:
IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE. DATA DIVISION. WORKING-STORAGE SECTION. 01 NUM PIC 9(3). PROCEDURE DIVISION.
DISPLAY "HELLO". STOP RUN.