I want to generate a number between 0 and 4 (possible values: 0,1,2,3,4) that will be then stored in the "nbr" variable.
- How to achieve the following using the rand () function?
int Random (int _iMin, int _iMax)
return (_iMin + (rand () % (_iMax-_iMin+1)));
int main (void)
srand (time (NULL));
iRandom = Random (50,100);
printf ("Random : %d", iRandom);
Thanks to scoubidou944
for this tip.
Published by deri58
Latest update on October 17, 2012 at 09:01 AM by deri58.