Displaying Source Code(s)
|
|
PRIME NUMBER
--------------------------------------------------------------------------------
Description : This Program identifies whethr a given number is
prime or not.
IDENTIFICATION DIVISION.
PROGRAM-ID. PRIME.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 N PIC 9(3).
77 Q PIC 9(3).
77 R PIC 9(3).
77 I PIC 9(3) VALUE 1.
PROCEDURE DIVISION.
PARA-A.
DISPLAY ( 1 , 1 ) ERASE.
DISPLAY ( 2 , 1 ) "ENTER AN INTEGER:".
ACCEPT ( 2 , 20 ) N.
IF N = 1
DISPLAY ( 3 , 1 ) "NUMBER IS NOT PRIME"
GO TO STOP-PARA.
PARA-B.
ADD 1 TO I.
IF I = N
DISPLAY ( 3 , 1 ) "NUMBER IS PRIME"
GO TO STOP-PARA.
DIVIDE N INTO I GIVING Q REMAINDER R.
IF R = 0
DISPLAY ( 3 , 1 ) "NUMBER IS NOT PRIME"
GO TO STOP-PARA.
GO TO PARA-B.
STOP-PARA.
STOP RUN.
-------------------------------------------------------------------------------- |
|
|