Monday, April 30, 2018

Adding modulo on the random function

in Rock, Paper, Scissors earlier this week, some students generated random numbers like this: rand()%3, and others did this: rand()%100+1

How are they different? Which way do you think is better and why?
Those percentages are called modulo and they set a limit on the random generator. For example the 100+1 is to find a random number from 1-100. There isn't a better or worse on because it all depends on the certain project.

No comments:

Post a Comment