TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

COBOL - CONTINUE Statement


The CONTINUE statement allows you to specify a no operation statement. CONTINUE indicates that no executable instruction is present.

Basically, The CONTINUE statement transfers the control to the next COBOL statement which come next in the program flow.

CONTINUE Statement - Format:

CONTINUE

The CONTINUE statement can be used anywhere a conditional statement or an imperative statement can be used. It has no effect on the execution of the program.


Example:

Let us see an example below will display the percentage if student passed all subjects or displays how many subjects failed

If any student marks are below 35 while adding the marks to calculate percentage, CONTINUE will simply pass the control to next iteration without interrupting the process.

  IDENTIFICATION DIVISION.
  PROGRAM-ID. CBLCONTU.

  ENVIRONMENT DIVISION.
  DATA DIVISION.
  WORKING-STORAGE SECTION.
  01 STD-MARKS                 PIC 9(03).
  01 TOTAL-MARKS               PIC 9(03) VALUE ZEROES.
  01 STD-PERCENT               PIC 9(03).9(02).
  01 I                         PIC 9(01) VALUE ZEROES.
  01 J                         PIC 9(01) VALUE ZEROES.

  PROCEDURE DIVISION.
      MOVE ZEROES     TO TOTAL-MARKS.

* Logic below to get 5 subject marks from input.
      PERFORM VARYING I FROM 1 BY 1 UNTIL I > 5
        SET STD-INDEX TO 1
        ACCEPT STD-MARKS
        IF STD-MARKS < 35
           CONTINUE
        ELSE
           ADD STD-MARKS  TO TOTAL-MARKS
           COMPUTE J = J + 1
        END-IF
      END-PERFORM.

* Logic below display student result.
      IF J < 5
         COMPUTE J = I -(J + 1)
         DISPLAY 'STUDENT FAILED IN 'J 'SUBJECTS
      ELSE
         COMPUTE STD-PERCENT = TOTAL-MARKS/5
         DISPLAY 'STUDENT PERCENTAGE : ' STD-PERCENT.
      END-IF.
      STOP RUN.

OUTPUT:

If student pass on all 5 subjects, then program display 'STUDENT PERCENTAGE : ' STD-PERCENT. Where STD-PERCENT hold the value 0f student percentage.

If student failed in any 1 subject, then program display 'STUDENT FAILED IN 'J 'SUBJECTS. Where J hold the value of number of subject student failed.


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal