Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com From: "Harold Hunt" To: , Subject: RE: Random Number Generator Date: Mon, 30 Apr 2001 15:14:02 -0400 Message-ID: <002101c0d1a9$b8437240$2fab0a23@huntharo> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 In-Reply-To: <32.143dcec3.281efce6@aol.com> Importance: Normal Beginning CS student? Thought so :) Let me teach you how to debug your program: 1) Change your line that calls rand () to: input1 = rand (); 2) Notice that random numbers are now generated. 3) Have your program print out the value of RAND_MAX: printf ("RAND_MAX: %d\n", RAND_MAX); 4) Calculate the result, in integer math, when dividing any integer smaller than RAND_MAX by RAND_MAX. (Hint: the answer is zero) 5) Realize that what you really wanted was something like: // Get random numbers from 0 and 9, inclusive input1 = rand () % 10; // Get random numbers from 1 and 10, inclusive input1 = 1 + rand () % 10; That was your freebie, from now on, ask general programming questions to a list that is more suited to answering such questions; or, better yet, read some programming books :) Harold -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple