Hi guys i just can't write the rand() to return specific number from 0 up to 6.
Can anybody help me out.
Thanks alot.
Printable View
Hi guys i just can't write the rand() to return specific number from 0 up to 6.
Can anybody help me out.
Thanks alot.
Try this
int random = (int)((double)rand()/(double)RAND_MAX * 6.0);
This should give random numbers from and including 0 up to and
including 6.
Why not just:
int randomValue = rand() % 6;
That's better than casting all over the place.