okay, I know that the following will give me a number between 0 and 100; however, if I wanted to go from 0 to a number n, how would i do that ? Perhaps 44 or any number ?? Thanks
Code:srandom(time(0)); win=random()%100;
okay, I know that the following will give me a number between 0 and 100; however, if I wanted to go from 0 to a number n, how would i do that ? Perhaps 44 or any number ?? Thanks
Code:srandom(time(0)); win=random()%100;
Same thing, but replace the literal with a variable :-)
Code:srandom(time(0)); win=random()%n;
*Cela*
Btw: I'm pretty sure win=random()%100; would give you a number between 0 & 99, not 0 & 100. So in your function you may want to use (n+1) as the variable.
ie
Code:int n=44; srandom(time(0)); win=random()%(n+1); // Gives a random number between 0 & n (inclusive)
Demonographic rhinology is not the only possible outcome, but why take the chance
Thank you.