Multiple choice technology programming languages

"What will be the output of the following snippet: MOVE ZERO TO WS-COUNT IF WS-COUNT = 0 NEXT SENTENCE END-IF ADD +1 TO WS-COUNT. DISPLAY 'VALUE OF WS-COUNT: ' WS-COUNT "

  1. VALUE OF WS-COUNT: 0

  2. VALUE OF WS-COUNT: 1

  3. Compile error

  4. None of the above

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

WS-COUNT starts at ZERO (0). The IF condition is true, so NEXT SENTENCE executes. In COBOL, NEXT SENTENCE skips to the next statement after the next period (sentence terminator). Since END-IF is not a period, and the ADD statement comes after END-IF in the same sentence, NEXT SENTENCE within the IF would skip over both the IF body AND the ADD statement until it finds the next period. Thus WS-COUNT remains 0.