Change Random number



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Change Random number

Postby thia_88 » Thu May 22, 2014 12:30 pm

Thanks to everyone for your guidance.
Appreciated much.
This is the code which produce the 4 digit random-numbers.

IDENTIFICATION DIVISION.
PROGRAM-ID. RANDOMWORK.
DATA DIVISION.
WORKING-STORAGE SECTION.

01 RANDOM-NUMBER PIC 9(4).
01 S PIC 9(4).
01 A PIC 9(4) VALUE 65.

PROCEDURE DIVISION.
PERFORM VARYING S FROM 099 BY 1 UNTIL S > 1999
COMPUTE RANDOM-NUMBER = FUNCTION MOD(123456789123,S) + 99
IF RANDOM-NUMBER > 2000
COMPUTE RANDOM-NUMBER = RANDOM-NUMBER - A
END-IF
DISPLAY RANDOM-NUMBER
END-PERFORM.
STOP RUN.

Thanks,
Rati
thia_88
 
Posts: 12
Joined: Wed May 07, 2014 8:48 am
Has thanked: 0 time
Been thanked: 0 time

Re: Re: Change Random number

 

Re: Change Random number

Postby enrico-sorichetti » Thu May 22, 2014 5:58 pm

:shock: :shock: :shock:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2707
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 139 times

Re: Change Random number

Postby thia_88 » Tue Jun 24, 2014 2:14 pm

:arrow: :idea:
thia_88
 
Posts: 12
Joined: Wed May 07, 2014 8:48 am
Has thanked: 0 time
Been thanked: 0 time

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post