random numbers 
Author Message
 random numbers

How do you get a random number in Pascal?


Wed, 25 May 2005 04:03:30 GMT  
 random numbers

Quote:

> How do you get a random number in Pascal?

You either program it yourself (look up linear congruential,
and/or mersenne twister and/or Knuth TAOCP) or you use an
implementation that has a (non-standard) extension to supply them.

--

   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!



Wed, 25 May 2005 06:45:51 GMT  
 random numbers
See www.moorecad.com/standardpascal

Under the FAQ

Quote:

> How do you get a random number in Pascal?



Wed, 25 May 2005 10:01:16 GMT  
 random numbers

Quote:

> How do you get a random number in Pascal?

Which Pascal are you talking about?

In Turbo Pascal it should be:

var myrannum : byte;

begin
 myrannum:=random(100); {pick a number between 0-100}
 writeln(myrannum);     {display it}
end.

Untested of course.

Finally, don't post to 'comp.lang.pascal', it's no longer used!

Ross.



Wed, 25 May 2005 10:10:38 GMT  
 random numbers

Quote:

> How do you get a random number in Pascal?

Covered in

 165966 Jan 8 2000 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers, linked

   All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa

Timo's  FAQ  materials  at   http://www.uwasa.fi/~ts/http/tsfaq.html



Wed, 25 May 2005 15:09:11 GMT  
 random numbers



posted at Fri, 6 Dec 2002 20:03:30 :-

Quote:
>How do you get a random number in Pascal?

If your understanding of the operation of News and of the nature of
Pascal is such that you think it reasonable to cross-post such a
question to all those newsgroups (one of which was removed over seven
years ago), in spite of what it says in "The weekly FAQ item about the
Pascal newsgroups' reorganization", and to do so without giving any
indication of the version or versions of Pascal that you are interested
in, then it seems to me that you should consider finding some other
occupation.

You should also seek a correctly-configured news server.

You should type shift-F1 in the IDE, type the word Random followed by
Enter, and read on, also reading about Randomize.  If that does not
work, you are probably using a less popular version of Pascal (I cannot
say whether the converse is true).

--

  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.



Wed, 25 May 2005 20:06:56 GMT  
 random numbers

Quote:
>>How do you get a random number in Pascal?

> Which Pascal are you talking about?

> In Turbo Pascal it should be:

> var myrannum : byte;

> begin

Ross: you forgott this:

    randomize;

otherwise the program will give you often the same random number if
startet in short intervals again (e.g. during tests within the IDE)

Quote:
>  myrannum:=random(100); {pick a number between 0-100}
>  writeln(myrannum);     {display it}
> end.

Greetings

Markus



Wed, 25 May 2005 21:20:52 GMT  
 random numbers
danke schoen


Quote:
> See www.moorecad.com/standardpascal

> Under the FAQ


> > How do you get a random number in Pascal?



Thu, 26 May 2005 01:58:11 GMT  
 random numbers

Quote:

> >>How do you get a random number in Pascal?

> > Which Pascal are you talking about?

> > In Turbo Pascal it should be:

> > var myrannum : byte;

> > begin

> Ross: you forgott this:

>     randomize;

> otherwise the program will give you often the same random number if
> startet in short intervals again (e.g. during tests within the IDE)

Yes if you want to set a random seed, however I deliberately left it out
thinking I maybe giving away the total answer to a student! :-)

But for general purpose Random Numbers which do not need any Random Seeds to
be set 'randomize;' isn't required.

With Regards,
Ross.



Sat, 28 May 2005 14:06:19 GMT  
 random numbers

2002, to amuse us all by posting to comp.lang.pascal:

Quote:
> How do you get a random number in Pascal?

Ctrl+F1 could give you more detail.

Here's 3 different methods.

[code]
uses crt;
  var Num:integer;
      Ch:char;

begin
  clrscr;
  randomize;
  repeat

{results between 0 and 9}
    writeln('0-9: ',random(10));

{results between 1 and 10}
    writeln('1-10: ',random(10)+1);

{using a variable}
    Num:= random(10)+1;
    writeln('Using variable: ',Num);

{in older versions before BTP 4.0, change to Ch:=readkey to read(kbd,Ch);}
    Ch:=readkey;
    clrscr;
  until Ch=#27; {Esc key}
end.
[/code]

--
The pool on the roof must have sprung a leak.



Tue, 31 May 2005 10:52:32 GMT  
 random numbers


Quote:

>2002, to amuse us all by posting to comp.lang.pascal:

>> How do you get a random number in Pascal?

>Ctrl+F1 could give you more detail.

You're answering in the wrong newsgroup.
This is the "Non-Borland" Pascal newsgroup.
Quote:

>Here's 3 different methods.

>[code]
>uses crt;
>  var Num:integer;
>      Ch:char;

>begin
>  clrscr;
>  randomize;
>  repeat

>{results between 0 and 9}
>    writeln('0-9: ',random(10));

>{results between 1 and 10}
>    writeln('1-10: ',random(10)+1);

>{using a variable}
>    Num:= random(10)+1;
>    writeln('Using variable: ',Num);

>{in older versions before BTP 4.0, change to Ch:=readkey to read(kbd,Ch);}
>    Ch:=readkey;
>    clrscr;
>  until Ch=#27; {Esc key}
>end.
>[/code]



Tue, 07 Jun 2005 06:58:59 GMT  
 random numbers



Dec 2002 17:58:59 :-

Quote:
>>Ctrl+F1 could give you more detail.

>You're answering in the wrong newsgroup.
>This is the "Non-Borland" Pascal newsgroup.

Please learn how to use your newsreader, or obtain one with adequate
capabilities.  Meanwhile, ponder the meaning of "This" under the
circumstances.

--

 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
     Check boilerplate spelling -- error is a public sign of incompetence.
    Never fully trust an article from a poster who gives no full real name.



Tue, 07 Jun 2005 21:21:31 GMT  
 random numbers
On Fri, 20 Dec 2002 13:21:31 +0000, Dr John Stockton

Quote:




>Dec 2002 17:58:59 :-
>>>Ctrl+F1 could give you more detail.

>>You're answering in the wrong newsgroup.
>>This is the "Non-Borland" Pascal newsgroup.

>Please learn how to use your newsreader, or obtain one with adequate
>capabilities.  Meanwhile, ponder the meaning of "This" under the
>circumstances.

Please post all complaints to me at my bogus address, where it will
be appropriately filed away, or learn to not bother the regular users.


Wed, 08 Jun 2005 22:39:48 GMT  
 random numbers

all by posting to comp.lang.pascal.borland:

Quote:

> You're answering in the wrong newsgroup.
> This is the "Non-Borland" Pascal newsgroup.

Umm, and that's why this newsgroup says comp.lang.pascal.borland right?

When the question was originally posted, it was cross-posted to many
newsgroups, including this BORLAND one, and the one you are reading it
from.

--
The pool on the roof must have sprung a leak.



Fri, 17 Jun 2005 10:42:48 GMT  
 
 [ 20 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Newbie: Random number between 2 numbers...

2. Random numbers /Time DOS-Interrupt using TP6 on NT4

3. random numbers

4. how to generate a random number???

5. Help with a random number generator...

6. Random Numbers

7. Uniform Random Number Generator

8. Problems concerning random number generator

9. random numbers

10. Random numbers /Time DOS-Interrupt using TP6 on NT4

11. random number generator

12. random number generator

 

 
Powered by phpBB® Forum Software