Advertisement
igovasconcelos

Untitled

Aug 24th, 2020
2,868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.43 KB | None | 0 0
  1. IDENTIFICATION DIVISION.
  2.             PROGRAM-ID. CONDITIONALS.
  3.             DATA DIVISION.
  4.               WORKING-STORAGE SECTION.
  5.               *> setting up places to store values
  6.               *> no values set yet
  7.               01 NUM1 PIC 9(9).
  8.               01 NUM2 PIC 9(9).
  9.               01 NUM3 PIC 9(5).
  10.               01 NUM4 PIC 9(6).
  11.               *> create a positive and a negative
  12.               *> number to check
  13.               01 NEG-NUM PIC S9(9) VALUE -1234.
  14.               *> create variables for testing classes
  15.               01 CLASS1 PIC X(9) VALUE 'ABCD '.
  16.               *> create statements that can be fed
  17.               *> into a cobol conditional
  18.               01 CHECK-VAL PIC 9(3).
  19.                 88 PASS VALUES ARE 041 THRU 100.
  20.                 88 FAIL VALUES ARE 000 THRU 40.
  21.             PROCEDURE DIVISION.
  22.               *> set 25 into num1 and num3
  23.               *> set 15 into num2 and num4
  24.               MOVE 25 TO NUM1 NUM3.
  25.               MOVE 15 TO NUM2 NUM4.
  26.               *> comparing two numbers and checking for equality
  27.               IF NUM1 > NUM2 THEN
  28.                 DISPLAY 'IN LOOP 1 - IF BLOCK'
  29.                 IF NUM3 = NUM4 THEN
  30.                   DISPLAY 'IN LOOP 2 - IF BLOCK'
  31.                 ELSE
  32.                   DISPLAY 'IN LOOP 2 - ELSE BLOCK'
  33.                 END-IF
  34.               ELSE
  35.                 DISPLAY 'IN LOOP 1 -ELSE BLOCK'
  36.               END-IF
  37.             STOP RUN.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement