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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 i pic 9(3).
01 j pic 9(3).
01 c pic 9(2).
01 d pic 9(2).
01 r pic 9(2).
01 n pic 9(3).
PROCEDURE DIVISION.
accept n.
perform varying i from 1 by 1 until i > n
move 0 to c
perform varying j from 1 by 1 until j > i
divide i by j giving d remainder r
if r = 0
add 1 to c
end-if
end-perform
if c = 2
display i
end-if
end-perform.


STOP RUN.

Is This Answer Correct ?    5 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I like to know if possible to use %TRIM or any statement with prefiv "%" like RPG ile programs. thanks

2488


What is perform?

1100


Explain the input procedure?

946


Explain the difference between search and searchall?

869


Explain the syntax of sort?

977


Explain the input procedure and output procedure?

915


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

965


What is the syntax of sort?

904


Define sort?

1186


Explain the output procedure?

1041


What is redefine?

1229


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

1150


What are the types of perform?

1044


What is sort? And its syntax?

1057


Explain the difference between section, paragraph and sentences?

981