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


Correct Option: C

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.

Find more quizzes: