Multiple choice technology mainframe

PIC S999 VALUE 5231. What would be the value getting stored in memory?

  1. 523

  2. 231

  3. +523

  4. -523

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

PIC S999 defines a 3-digit signed numeric field. The VALUE 5231 provides 4 digits, but the field can only store 3 digits. When a larger value is assigned to a smaller field, COBOL takes the rightmost 3 digits. The 'S' indicates the field can hold a sign, but since 5231 doesn't have an explicit sign, only 231 is stored. The value would be stored as 231 (positive by default).