How to write a multiple‑choice question implemented in COBOL

1 Answer

0 votes
       IDENTIFICATION DIVISION.
       PROGRAM-ID. MCQ-COBOL.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 USER-ANSWER PIC A(1).        *> Stores the user's choice

       PROCEDURE DIVISION.
           DISPLAY "Multiple-Choice Question:"
           DISPLAY "What does COBOL stand for?"
           DISPLAY "A. Common Business-Oriented Language"
           DISPLAY "B. Computer Binary Operating Logic"
           DISPLAY "C. Central Business Operations Layer"
           DISPLAY "D. Code Base Optimization Language"
           DISPLAY " "
           DISPLAY "Enter your answer (A/B/C/D): "
           ACCEPT USER-ANSWER

           IF USER-ANSWER = "A"
               DISPLAY "Correct! COBOL means Common Business-Oriented Language."
           ELSE
               DISPLAY "Incorrect. The correct answer is A."
           END-IF

           STOP RUN.



    *> run:
    *>
    *> Multiple-Choice Question:
    *> What does COBOL stand for?
    *> A. Common Business-Oriented Language
    *> B. Computer Binary Operating Logic
    *> C. Central Business Operations Layer
    *> D. Code Base Optimization Language
    *>
    *> Enter your answer (A/B/C/D): 
    *> A
    *> Correct! COBOL means Common Business-Oriented Language.
    *>

 



answered Jun 5 by avibootz
...