answersLogoWhite

0

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.

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
BeauBeau
You're doing better than you think!
Chat with Beau
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: Write a cobol program to find prime number or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp