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
What is input procedure?
Explain the difference between search and searchall?
What are fillers?
I like to know if possible to use %TRIM or any statement with prefiv "%" like RPG ile programs. thanks
How to detect record is locked in cobol/400? What is the solution for that?
Define perform?
Explain how to detect record is locked in cobol/400? What is the solution for that?
How to detect record is locked in cobol/400?
How to update data area in cobol 400 program?
Explain the syntax of sort?
Explain the output procedure?
Explain the types of perform?
Explain the difference between section, paragraph and sentences?
Explain the difference between comp & comp-3?
Explain what all the conditiones required for using open opcode on a file?