Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / surya

IDENTIFICATION DIVISION.
PROGRAM-ID. PRIME.
AUTHOR. SURYA.
INSTALLATION. PEARSON-PVT-LTD.
DATE-WRITTEN. 20/01/2016.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
OBJECT-COMPUTER. IBM-AS400.
SOURCE-COMPUTER. IBM-AS400.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP-VAL PIC 9(3).
01 WRK-VAL PIC 9(3).
01 I PIC 9(3).
01 QUT PIC 9(2).
01 QUT1 PIC 9(2).
01 REM PIC 9(2).
01 FLAG PIC X(1).

PROCEDURE DIVISION.

STEP-1.
MOVE 40 TO INP-VAL.
DISPLAY "Please find the prime numbers below:".
IF INP-VAL > 2 THEN DISPLAY "02".
PERFORM STEP-2 VARYING WRK-VAL FROM 3 BY 1 UNTIL WRK-VAL > INP-VAL.
STOP RUN.

STEP-2.
MOVE "Y" TO FLAG.
INITIALIZE REM, QUT, QUT1.
DIVIDE WRK-VAL BY 2 GIVING QUT.
PERFORM STEP-3 VARYING I FROM 2 BY 1 UNTIL I > QUT.
IF FLAG = 'Y' THEN DISPLAY WRK-VAL.

STEP-3.
INITIALIZE REM, QUT1.
DIVIDE WRK-VAL BY I GIVING QUT1 REMAINDER REM.
IF REM = 0 THEN MOVE "N" TO FLAG.

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are fillers?

1029


What is output procedure?

993


How to update data area in cobol 400 program?

1043


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

956


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

1144


Explain the difference between comp & comp-3?

953


Explain how to update data area in cobol 400 program?

1013


How to detect record is locked in cobol/400? What is the solution for that?

963


Define perform? And its types?

979


Explain the output procedure?

1032


What is the syntax of redefine?

945


What is the actual use of fillers?

957


Explain the types of perform?

1007


Define perform?

991


Define redefine and its syntax?

966