write a cobol program to display prime numbers between 1 to 100?

Answer Posted / satyabrata nanda

Logic:
01 Var.
05 VarX Pic 9(2) Value zeros.
05 QNT Pic 9(2) value zeros.
05 REM Pic 9(2) value zeros.
05 CNT Pic 9(2) value zeros.
Procedure Div.

Display ' Enter VarX = '
Accept VarX.
If VarX = '1'
Display 'Prime no'
Else
Perform varying CNT from 2 by 1 until CNT >= VarX
Divide CNT into VarX giving QNT reminder REM
If rem > zero
Display 'Prime No'
Else
Display 'Not Prime'
End-if
End-if.

Is This Answer Correct ?    4 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define sort?

581


Explain what all the conditiones required for using open opcode on a file?

500


Explain the output procedure?

573


What is output procedure?

541


Define redefine and its syntax?

542






How to detect record is locked in cobol/400?

536


What is redefine?

551


Explain the syntax of sort?

557


Define redefine?

557


Explain the difference between comp & comp-3?

543


What is comp?

549


What is input procedure?

578


Explain how to convert 2010/02/11 to m/dd/yyy.. With string and without string if any other method... Code?

642


What are the types of perform?

567


seqence numbers in cobol

2656