¨ SUBSTRACT Verb
Digunakan untuk operasi pengurangan suatu nilai data numerik.
BU :
SUBSTRACT nama-data-1 , nama-data-2
literal-1 literal2
FROM nama-data-n GIVING nama-data-m
literal-n
[ROUNDED] [;ON SIZE ERROR imperative statement]
¨ MULTIPLY Verb
Digunakan untuk mengalikan 2 nilai numerik dan menyimpan hasilnya.
BU 1 :
MULTIPLY nama-data-1 BY nama-data-2
literal-1
BU 2 :
MULTIPLY nama-data-1 BY nama-data-2
literal-1 literal-2
GIVING nama-data-3 [ROUNDED]
[; ON SIZE ERROR imperative statement]
¨ DIVIDE Verb
Digunakan untuk membentuk statement operasi pembagian.
BU 1 :
DIVIDE nama-data-1 INTO nama-data-2 [ROUNDED]
literal-1
[ ; ON SIZE ERROR imperative statement]
BU 2 :
DIVIDE nama-data-1 INTO nama-data-2
literal-1 literal-2
GIVING nama-data-3 [ROUNDED]
[ ; ON SIZE ERROR imperative statement]
BU 3 :
DIVIDE nama-data-1 BY nama-data-2
literal-1 literal-2
GIVING nama-data-3 [ROUNDED]
[ ; ON SIZE ERROR imperative statement]
BU 4 :
DIVIDE nama-data-1 INTO nama-data-2
literal-1 literal-2
GIVING nama-data-3 [ROUNDED]
REMAINDER nama-data-4
[ ; ON SIZE ERROR imperative statement]
BU 5 :
DIVIDE nama-data-1 BY nama-data-2
literal-1 literal-2
GIVING nama-data-3 [ROUNDED]
REMAINDER nama-data-4
[ ; ON SIZE ERROR imperative statement]
¨ COMPUTE
Digunakan untuk operasi yang lebih rumit, untuk menyederhanakan 4 arithmatic verb sebelumnya.
BU :
COMPUTE nama-data-1 [ROUNDED] = ungkapan aritmatika
[ ; ON SIZE ERROR imperative statement]
¨ GO TO Verb
Digunakan untuk alih kontrol tanpa syarat ke paragraph tertentu.
BU :
GO TO nama-paragraph
¨ GO TO … DEPENDING Verb
Digunakan untuk alih kontrol bersyarat. Beralih pada paragraph tertentu dengan kondisi tertentu.
BU :
GO TO nama-paragraph-1, nama-paragraph-2, … nama-paragraph-n
DEPENDING ON nama-data
¨ ALTER Verb
Digunakan untuk merubah arah tujuan proses dari statement GO TO yang telah ada di program.
BU :
ALTER nama-paragraph-1 TO [ PROCEED TO] nama-paragraph-2
¨ PERFORM Verb
Digunakan untuk membuat suatu statement yang akan membawa proses dari program meloncat kesuatu paragraph, kemudian menjalankan seluruh statetement yang ada pada paragraph tersebut. Jika telah selesai akan kembali ke statement setelah PERFORM.
BU :
PERFORM nama-paragrapg-1 THROUGH nama-paragraph-2
THRU
Contoh Program Looping
IDENTIFICATION DIVISION.
PROGRAM-ID. ADDPROG.
AUTHOR. AMELIA.
*ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INPUT-AREA.
05 GET-ACCEPT-ANS PIC X VALUE SPACES.
05 FIRST-NUMBER PIC 999 VALUE 0.
05 SECOND-NUMBER PIC 999 VALUE 0.
05 ADD-ANS PIC 9999 VALUE 0.
PROCEDURE DIVISION.
MAINLINE.
DISPLAY “ENTER THE FIRST NUMBER (UNDER 1000)”.
ACCEPT FIRST-NUMBER.
DISPLAY “ENTER THE SECOND NUMBER (UNDER 1000)”.
ACCEPT SECOND-NUMBER.
ADD FIRST-NUMBER TO SECOND-NUMBER
GIVING ADD-ANS.
DISPLAY “THE ANSWER IS ” ADD-ANS.
DISPLAY “PRESS ENTER TO END THE PROGRAM”.
ACCEPT GET-ACCEPT-ANS.
STOP RUN.
PROGRAM-ID. ADDPROG.
AUTHOR. AMELIA.
*ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INPUT-AREA.
05 GET-ACCEPT-ANS PIC X VALUE SPACES.
05 FIRST-NUMBER PIC 999 VALUE 0.
05 SECOND-NUMBER PIC 999 VALUE 0.
05 ADD-ANS PIC 9999 VALUE 0.
PROCEDURE DIVISION.
MAINLINE.
DISPLAY “ENTER THE FIRST NUMBER (UNDER 1000)”.
ACCEPT FIRST-NUMBER.
DISPLAY “ENTER THE SECOND NUMBER (UNDER 1000)”.
ACCEPT SECOND-NUMBER.
ADD FIRST-NUMBER TO SECOND-NUMBER
GIVING ADD-ANS.
DISPLAY “THE ANSWER IS ” ADD-ANS.
DISPLAY “PRESS ENTER TO END THE PROGRAM”.
ACCEPT GET-ACCEPT-ANS.
STOP RUN.
0 komentar:
Posting Komentar