123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

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.
--------------------------------------------------------------------------------

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG