Sunday, 11 October 2009

PROGRAM BILANGAN PRIMA PADA COBOL

PROGRAM BILANGAN PRIMA PADA COBOL

IDENTIFICATION DIVISION.
PROGRAM-ID. PRIMA.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 BILANGAN.
02 X PIC 99.
02 Z PIC 99.
02 HASIL PIC 99.
02 SISA PIC 99.
SCREEN SECTION.
01 HAPUS-LAYAR.
02 BLANK SCREEN.
PROCEDURE DIVISION.
MULAI.
DISPLAY HAPUS-LAYAR.
DISPLAY (1, 1) 'MASUKKAN BILANGAN INTEGER : ', ACCEPT X.
COMPUTE Z = 2.
DIVIDE Z INTO X GIVING HASIL REMAINDER SISA.
KONDISI.
IF SISA = 0
GO TO JAWAB
ELSE
GO TO HITUNG.
JAWAB.
IF Z = X
DISPLAY X, 'BILANGAN PRIMA'
ELSE
DISPLAY X, 'BUKAN BILANGAN PRIMA'.
GO TO SELESAI.
HITUNG.
COMPUTE Z = Z + 1.
DIVIDE Z INTO X GIVING HASIL REMAINDER SISA.
GO TO KONDISI.
SELESAI.
STOP RUN.


OUTPUT :

MASUKKAN BILANGAN PRIMA : 7
07 BILANGAN PRIMA


SELAMAT MENCOBA...

Posting Terkait

0 comments:

Post a Comment

Mikail Alfith Amarullah

↑ Grab this Headline Animator

IKLAN

  © Blogger Tamplates

Back to TOP