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 / 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


Please Help Members By Posting Answers For Below Questions

What is sort?

958


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

1150


why icetool be used in programmer view?

2578


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

971


How to update data area in cobol 400 program?

1048


What is perform?

1101


What are fillers?

1039


Define redefine?

1128


Define redefine and its syntax?

980


Explain the difference between search and searchall?

869


Explain the difference between section, paragraph and sentences?

983


What is output procedure?

1003


What is the syntax of sort?

904


What is redefine?

1230


What is the actual use of fillers?

967