Thread: I didnt notice this about random :(

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    114

    I didnt notice this about random :(

    With the rand() function rand keeps going higher with the number ex: 4 then 15 then 27 then 35 then 41 then 61 then 85 then 99 then 1 < until it reaches the number its max is any way to make that obsolete or is it just the way rand works

    even if u first have max as 200 and min as 1 and it comesx out with 56 if u do 100 and min 1 it will be higher
    Code:
    #include<iostream>
    #include<cmath>
    #include<ctime>
    
    using namespace std;
    
    int main()
    {
        int random;
        int max;
        int min;
        while(random)
        {
                     cout << "Enter a max: ";
                     cin >> max;
                     cout << "Enter a min: ";
                     cin >> min;
        srand(time(NULL));             
        random =(rand() % max) + min;
        cout <<"Hey the numbereno is " << random << "\n";
        }
    }
    also im still looking for a sure way that max will always be the highst number reachable and min will always be the lowest cause for some reason if 2000 is max and min then the answer is liek 3759
    Last edited by Nathan the noob; 02-21-2009 at 06:41 PM.
    Who needs a signature?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random to int?
    By psyadam in forum C# Programming
    Replies: 7
    Last Post: 07-22-2008, 08:09 PM
  2. Lesson #3 - Math
    By oval in forum C# Programming
    Replies: 2
    Last Post: 04-27-2006, 08:16 AM
  3. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  4. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 04:11 PM