Multiple choice technology mainframe

If someone wanted a COBOL perform "loop" to execute once before the condition is checked, which of the following would they do?

  1. Use a standard perform statement

  2. Use an in line perform

  3. Skillful use of the COBOL reserved word "AFTER"

  4. This is not possible in COBOL

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

The AFTER clause in COBOL PERFORM statements allows condition checking after initial execution, enabling the loop to run once before evaluation. Standard PERFORM checks first, inline PERFORM is about code placement, and the functionality is definitely possible in COBOL.

AI explanation

To answer this question, you need to understand how the COBOL perform statement works.

Option A) Use a standard perform statement - This option is incorrect. The standard perform statement in COBOL executes the loop after checking the condition. It does not allow for the loop to execute once before the condition is checked.

Option B) Use an in-line perform - This option is incorrect. An in-line perform statement in COBOL is used to execute a section of code repeatedly until a condition is met. It does not provide the functionality to execute the loop once before the condition is checked.

Option C) Skillful use of the COBOL reserved word "AFTER" - This option is correct. By using the "AFTER" keyword in the perform statement, you can ensure that the loop executes once before the condition is checked. The code inside the perform loop will be executed once, and then the condition will be checked to determine whether the loop should continue or not.

Option D) This is not possible in COBOL - This option is incorrect. It is possible to achieve the desired behavior by using the "AFTER" keyword in the perform statement.

Therefore, the correct answer is option C. This option is correct because it allows the loop to execute once before the condition is checked.