View Single Post
Old 08-31-2008, 04:27 AM   #3 (permalink)
Baez
Baez's Avatar
 

Join Date: Sep 2005

Location: Toronto, Canada

Posts: 5,470

Baez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of light

Default Re: C - Random Number Generator!

Technically speaking there is no true random number generator. We studied it for a month in my C++ Advanced Algorithms course in college . You could however use srand like bla said and use a null value for time.

Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main()
{

srand(time(NULL));
printf("%d", rand() % 10000);

}
Something like that will generate a number out of 10000 each time you run it. Just put it in a for loop to run it X amount of times.
__________________

Baez is online now