Arithmetic
Calculation with COMPUTE and remainder with FUNCTION MOD. (Numbers are padded to fit the PIC definition.)
Simple enough for a 5-year-old to understand
COMPUTE
COMPUTE calculates a formula and writes the result to a variable. The result variable's PIC determines the number of digits.
IDENTIFICATION DIVISION. PROGRAM-ID. H. DATA DIVISION. WORKING-STORAGE SECTION. 01 R PIC 9. PROCEDURE DIVISION. COMPUTE R = 3 + 4. DISPLAY R. STOP RUN.🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)
🎯 Expected output: 3