Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

8.11. DEBUGGING EXERCISES

  1. Consider the following coding:

    .
         .
         .
         PERFORM UNTIL NO-MORE-RECORDS
             READ TRANS-FILE
                  AT END
                      MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
                  NOT AT END
                      PERFORM 200-CALC-RTN
             END-READ
         END-PERFORM
         .
         .
         .
    200-CALC-RTN.
         IF AMT1 5400
           ADD AMT2 TO TOTAL
         ELSE
           ADD 1 TO ERR-CT
         WRITE OUT-REC FROM DETAIL-REC.

    Under what conditions is a record written?

    (Hint: The punctuation is more critical here than the indentations.)

  2. The following coding will result in a syntax error. Explain why.

    IF AMT1 AMT2
       ADD AMT3 TO TOTAL.
    ELSE
       ADD AMT4 TO TOTAL.

  3. Consider the following specifications:

    01     REC-1.
         05 A        PIC X.
         05 B        PIC 9.
         05 C        PIC 9.

    (a) The following coding will result in a syntax error. Explain why.

    IF A IS POSITIVE
       PERFORM 900-GO-TO-IT.

    (b) Consider the following:

    IF A NOT EQUAL TO 6 OR
       A NOT EQUAL TO 7
       PERFORM 800-RTN-X.

    Will a syntax error result? Explain your answer. Under what condition will 800-RTN-X be performed?

    (c) Suppose that B was not initialized and you included the following coding in the PROCEDURE DIVISION:

    IF B = 6
       PERFORM 500-RTN5.

    Under what conditions, if any, will a syntax error occur? Under what conditions, if any, would a program interrupt occur?


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial