Multiple choice technology mainframe

Sample Code Field in working storage: 05 S-EOF-CHECK PIC X(01). 88 S-NOT-END-OF-FILE VALUE 'N'. 88 S-END-OF-FILE VALUE 'Y'. MAINLINE. SET S-END-OF-FILE TO TRUE PERFORM A0100-PRINT-DETAIL-AND-FOOTERS UNTIL S-END-OF-FILE END-PERFORM. Using the sample working storage and mainline section of a program, which one of the following is the coding error that occurred in the sample above?

  1. A READ statement is missing in the MAINLINE section after the PERFORM.

  2. MAINLINE must not contain any statements other than the PERFORM statement.

  3. S-EOF-CHECK is not properly initialized prior to the PERFORM statement

  4. The line "SET S-END-OF-FILE TO TRUE" is not a valid statement.

  5. In working storage, an 88 level must be defined for values of S-EOF-CHECK other than 'N' and 'Y'.

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

The SET statement sets S-END-OF-FILE to TRUE, which initializes S-EOF-CHECK to 'Y'. Since S-NOT-END-OF-FILE (value 'N') is not set, and no READ statement exists inside the loop to change the condition, the PERFORM loop's UNTIL condition is immediately satisfied - the loop won't execute at all. The proper pattern is to initialize S-NOT-END-OF-FILE to TRUE before the PERFORM.

AI explanation

The code sets S-END-OF-FILE to TRUE immediately before the PERFORM ... UNTIL S-END-OF-FILE loop, which means the loop's exit condition is already satisfied before the loop even starts, so A0100-PRINT-DETAIL-AND-FOOTERS never executes. The flag should instead be initialized to S-NOT-END-OF-FILE so the loop can run until a subsequent read actually detects end of file.