Multiple choice technology mainframe

01 WS-ABCD PIC X(8) VALUE SPACES . . . INSPECT WS-ABCD TALLYING WS-COUNT FOR ALL SPACES DISPLAY WS-COUNT What will be the output?

  1. 0

  2. 1

  3. 8

  4. 5

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

WS-ABCD is initialized to SPACES, which in COBOL means 8 space characters. The INSPECT statement with TALLYING clause counts ALL occurrences of SPACES in the variable. Since the entire 8-character field contains spaces, all 8 characters are counted. WS-COUNT will be 8 after the INSPECT statement.