Hey,
I have noticed when you use srand or rand you write:

rand() % 99 + 1

I was wondering about the 1, is it just tradition to use it or is it from 1-99?
Just because i was wondering how i could make it between say 20 and 40 etc

Recommended Answers

All 3 Replies

Ok thank you, sorry for the mistake :S

I skimmed the article, but is the only problem with rand() that RAND_MAX may not be one less than a multiple of your maximum? Like if you do rand()%3, and RAND_MAX+1 is a multiple of 3, will that be truly random?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.