| delorie.com/archives/browse.cgi | search | 
| From: | "Richard Pett" <rpett AT sparky DOT niwa DOT cri DOT nz> | 
| Newsgroups: | comp.os.msdos.djgpp | 
| Subject: | Re: Randomizing | 
| Date: | Mon, 30 Nov 1998 11:08:40 +1300 | 
| Organization: | National Insitute of Water and Atmosphere (http://www.niwa.cri.nz) | 
| Lines: | 107 | 
| Message-ID: | <73sgr5$j64$1@clam.niwa.cri.nz> | 
| References: | <000701be197f$f2d2e100$79f5ffc2 AT default> | 
| NNTP-Posting-Host: | 161.65.68.240 | 
| Mime-Version: | 1.0 | 
| X-Trace: | clam.niwa.cri.nz 912377509 19652 161.65.68.240 (29 Nov 1998 22:11:49 GMT) | 
| X-Complaints-To: | postmaster AT niwa DOT cri DOT nz | 
| NNTP-Posting-Date: | 29 Nov 1998 22:11:49 GMT | 
| X-Newsreader: | Microsoft Outlook Express 4.72.2106.4 | 
| X-Mimeole: | Produced By Microsoft MimeOLE V4.72.2106.4 | 
| To: | djgpp AT delorie DOT com | 
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp | 
| Reply-To: | djgpp AT delorie DOT com | 
This is a multi-part message in MIME format.
------=_NextPart_000_01C6_01BE1C51.C95174C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
    Lazer ---=A4--- wrote in message =
<000701be197f$f2d2e100$79f5ffc2 AT default>...
    Would anyone show me how to use rand()!!
    =20
    I nede to get it to chose from 2 numbers
    =20
    i've tryed this:
    =20
    ***********************************
    #include <stdio.h>
    =20
    int main()
    {
    int my_number;
    my_number=3Drand()%2;
    printf("%d", my_number);
    }
    ***********************************
    =20
    It always print 0 on the screen
    =20
    Thanks!!
    =20
    ---> Lazer
   =20
    my_number=3Drand()*2 usually works for me.
   =20
    Richard Pett (r DOT pett AT niwa DOT cri DOT nz)
    National Institute of Water and Atmospheric Research
    NIWA, Box 8602                     Phone +64 3 3488987
    Christchurch, New Zealand     Fax   +64 3 3485548
------=_NextPart_000_01C6_01BE1C51.C95174C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 =
HTML//EN">
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV> </DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
    <DIV>Lazer ---¤---<LAZER_HASSING AT YAHOO DOT COM> wrote in message=20
    <000701be197f$f2d2e100$79f5ffc2 AT default>...</DIV>
    <DIV><FONT size=3D2>Would anyone show me how to use =
rand()!!</FONT></DIV>
    <DIV><FONT size=3D2></FONT> </DIV>
    <DIV><FONT size=3D2>I nede to get it to chose from 2 =
numbers</FONT></DIV>
    <DIV><FONT size=3D2></FONT> </DIV>
    <DIV><FONT size=3D2>i've tryed this:</FONT></DIV>
    <DIV><FONT size=3D2></FONT> </DIV>
    <DIV><FONT size=3D2>***********************************</FONT></DIV>
    <DIV><FONT size=3D2>#include <stdio.h></FONT></DIV>
    <DIV><FONT size=3D2></FONT> </DIV>
    <DIV><FONT size=3D2>int main()</FONT></DIV>
    <DIV><FONT size=3D2></FONT><FONT color=3D#000000 =
size=3D2>{</FONT></DIV>
    <DIV><FONT size=3D2>int my_number;</FONT></DIV>
    <DIV><FONT size=3D2>my_number=3Drand()%2;</FONT></DIV>
    <DIV><FONT size=3D2>printf("%d", my_number);</FONT></DIV>
    <DIV><FONT color=3D#000000 size=3D2>}</FONT></DIV>
    <DIV><FONT color=3D#000000=20
    size=3D2>***********************************</FONT></DIV>
    <DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
    <DIV><FONT color=3D#000000 size=3D2>It always print 0 on the =
screen</FONT></DIV>
    <DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
    <DIV><FONT color=3D#000000 size=3D2>Thanks!!</FONT></DIV>
    <DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
    <DIV><FONT color=3D#000000 size=3D2>---> Lazer</FONT></DIV>
    <DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
    <DIV><FONT color=3D#000000 size=3D2>my_number=3Drand()*2 usually =
works for=20
    me.</FONT></DIV>
    <DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
    <DIV><FONT color=3D#000000 size=3D2>Richard Pett (<A=20
    =
href=3D"mailto:r DOT pett AT niwa DOT cri DOT nz">r DOT pett AT niwa DOT cri DOT nz</A>)<BR>National=20
    Institute of Water and Atmospheric Research<BR>NIWA, Box=20
    =
8602           &nb=
sp;        =20
    Phone +64 3 3488987<BR>Christchurch, New =
Zealand    =20
    Fax   +64 3 =
3485548</FONT></DIV></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_01C6_01BE1C51.C95174C0--
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |