mercredi 26 octobre 2016

C - How do I use the

I've recently started my degree. One module is C.

I have been given various random number generator exercises to do but I don't understand the instructions given about how to use/implement the <stdlib.h> library and the rand() and srand() functions.

It also talks about int rand(void); and void srand(unsigned int seed);? What are these?

Within the instructions documents, there is also this string of code (which I do not know where to put or what it does for that matter):

random_number = (int) (1O.O*rand()/(RAND_MAX+1.O));

The first exercise is this:

  1. Mean Test - Calculate the mean of 1000 random numbers. the result should be close to 4.5.

Any help would be greatly appreciated! Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire