ZEROES in COBOL is a figurative constant that represents the numeric value zero. It is used for initializing variables, performing comparisons, and representing zero in calculations. ZEROES is an alternative plural form of the zero constant, with ZERO being the singular form and ZEROS being the primary plural form, though all represent the same value.
ZEROES usage patterns for initialization, comparisons, and calculations.
123456789101112131415IDENTIFICATION DIVISION. PROGRAM-ID. ZEROES-INITIALIZATION. DATA DIVISION. WORKING-STORAGE SECTION. 01 COUNTER PIC 9(4) VALUE ZEROES. 01 ACCUMULATOR PIC 9(8) VALUE ZEROES. 01 TOTAL-AMOUNT PIC 9(10)V99 VALUE ZEROES. 01 ITEM-COUNT PIC 9(3) VALUE ZEROES. PROCEDURE DIVISION. DISPLAY "Counter: " COUNTER DISPLAY "Accumulator: " ACCUMULATOR DISPLAY "Total Amount: " TOTAL-AMOUNT DISPLAY "Item Count: " ITEM-COUNT STOP RUN.
Basic ZEROES initialization of numeric variables.
12345678910111213141516171819202122232425262728293031IDENTIFICATION DIVISION. PROGRAM-ID. ZEROES-COMPARISONS. DATA DIVISION. WORKING-STORAGE SECTION. 01 AMOUNT PIC 9(6)V99 VALUE 150.75. 01 BALANCE PIC 9(8)V99 VALUE ZEROES. 01 TRANSACTION-COUNT PIC 9(4) VALUE 0. PROCEDURE DIVISION. * Check if amount is zero IF AMOUNT = ZEROES DISPLAY "Amount is zero" ELSE DISPLAY "Amount is not zero: " AMOUNT END-IF * Check if balance is zero IF BALANCE = ZEROES DISPLAY "Balance is zero" ELSE DISPLAY "Balance is not zero: " BALANCE END-IF * Check if transaction count is zero IF TRANSACTION-COUNT = ZEROES DISPLAY "No transactions processed" ELSE DISPLAY "Transactions processed: " TRANSACTION-COUNT END-IF STOP RUN.
ZEROES usage in conditional statements and comparisons.
1234567891011121314151617181920212223242526272829303132IDENTIFICATION DIVISION. PROGRAM-ID. ZEROES-ARITHMETIC. DATA DIVISION. WORKING-STORAGE SECTION. 01 VALUE-1 PIC 9(4) VALUE 100. 01 VALUE-2 PIC 9(4) VALUE ZEROES. 01 RESULT PIC 9(6). 01 QUOTIENT PIC 9(6). 01 REMAINDER PIC 9(4). PROCEDURE DIVISION. * Addition with ZEROES ADD ZEROES TO VALUE-1 GIVING RESULT DISPLAY "Value + ZEROES = " RESULT * Subtraction with ZEROES SUBTRACT ZEROES FROM VALUE-1 GIVING RESULT DISPLAY "Value - ZEROES = " RESULT * Multiplication with ZEROES MULTIPLY VALUE-1 BY ZEROES GIVING RESULT DISPLAY "Value * ZEROES = " RESULT * Division by ZEROES (error handling) IF VALUE-2 = ZEROES DISPLAY "Cannot divide by ZEROES" ELSE DIVIDE VALUE-1 BY VALUE-2 GIVING QUOTIENT REMAINDER REMAINDER DISPLAY "Division result: " QUOTIENT END-IF STOP RUN.
ZEROES usage in arithmetic operations with error handling.
Initialize numeric variables to zero.
12301 COUNTER PIC 9(4) VALUE ZEROES. 01 TOTAL PIC 9(8)V99 VALUE ZEROES. 01 BALANCE PIC S9(10)V99 VALUE ZEROES.
Check if values are zero.
1234567IF AMOUNT = ZEROES DISPLAY "Amount is zero" END-IF IF BALANCE NOT = ZEROES PERFORM PROCESS-BALANCE END-IF
Use ZEROES in calculations.
12345ADD ZEROES TO TOTAL MULTIPLY VALUE BY ZEROES GIVING RESULT IF DIVISOR = ZEROES DISPLAY "Division by zero error" END-IF
Use ZEROES for loop initialization.
12345MOVE ZEROES TO LOOP-COUNTER PERFORM UNTIL LOOP-COUNTER >= MAX-COUNT ADD 1 TO LOOP-COUNTER PERFORM PROCESS-ITEM END-PERFORM
Usage | Syntax | Purpose |
---|---|---|
Initialization | VALUE ZEROES | Initialize variables to zero |
Comparison | IF X = ZEROES | Check if value equals zero |
Arithmetic | ADD ZEROES TO X | Use in calculations |
Error Check | IF DIVISOR = ZEROES | Prevent division by zero |
1. What is the primary purpose of ZEROES in COBOL?
2. How does ZEROES compare to ZERO and ZEROS in COBOL?
3. What is the main use case for ZEROES in COBOL?
4. How does ZEROES behave in arithmetic operations?
5. What is a common use case for ZEROES in COBOL programs?