write a cobol program to display prime numbers between 1 to 100?
Answer Posted / d karthik
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 i pic 9(3).
01 j pic 9(3).
01 c pic 9(2).
01 d pic 9(2).
01 r pic 9(2).
01 n pic 9(3).
PROCEDURE DIVISION.
accept n.
perform varying i from 1 by 1 until i > n
move 0 to c
perform varying j from 1 by 1 until j > i
divide i by j giving d remainder r
if r = 0
add 1 to c
end-if
end-perform
if c = 2
display i
end-if
end-perform.
STOP RUN.
Is This Answer Correct ? | 5 Yes | 6 No |
Post New Answer View All Answers
Explain the output procedure?
seqence numbers in cobol
What is the actual use of fillers?
Define perform? And its types?
What are fillers? What is the actual use of fillers? With mall/simple example?
Explain the difference between section, paragraph and sentences?
Explain how to detect record is locked in cobol/400? What is the solution for that?
What is sort? And its syntax?
What is perform?
How to detect record is locked in cobol/400? What is the solution for that?
What is redefine?
Define sort?
Explain the syntax of redefine?
Explain the difference between comp & comp-3?
How to detect record is locked in cobol/400?