write a cobol program to display prime numbers between 1 to 100?
Answer Posted / amit mahajan
WORKING-STORAGE SECTION.
01 COUNTER PIC 99 VALUE ZEROES.
01 MAXLIMIT PIC 999 VALUE 100.
01 REM PIC 99 VALUE ZEROES.
01 QNT PIC 99 VALUE ZEROES.
01 NUM PIC 99 VALUE ZEROES.
01 I PIC 99.
PROCEDURE DIVISION.
PERFORM VARYING COUNTER FROM 2 BY 1 UNTIL COUNTER>=MAXLIMIT
MOVE 0 TO I
PERFORM VARYING NUM FROM 1 BY 1 UNTIL NUM > COUNTER
DIVIDE NUM INTO COUNTER GIVING QNT REMAINDER REM
IF REM=0
ADD 1 TO I
END-IF
END-PERFORM
IF I=2
DISPLAY COUNTER
END-IF
END-PERFORM
GOBACK.
| Is This Answer Correct ? | 6 Yes | 4 No |
Post New Answer View All Answers
Explain the input procedure and output procedure?
Explain the difference between section, paragraph and sentences?
What are fillers?
What is sort? And its syntax?
What is perform?
Explain the difference between comp & comp-3?
seqence numbers in cobol
Explain the syntax of redefine?
Define redefine and its syntax?
What is comp?
What is redefine?
Define perform? And its types?
Define sort?
How to detect record is locked in cobol/400?
Explain the types of perform?