Hi All
What does this code mean?
(The code of the if statement)Code:if((rand() % xincrease) == 0) AddLetter();
Thanx
Hi All
What does this code mean?
(The code of the if statement)Code:if((rand() % xincrease) == 0) AddLetter();
Thanx
rand() returns pseudorandom value from 0 to RAND_MAX inclusive
a % b gives reminder for division a to b
if reminder is zero - it means a == b * m for some m
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Will increasing xincrease (ie, 'b') increase the probability of the statement being true?
>Will increasing xincrease (ie, 'b') increase the probability of the statement being true?
No, decreasing it will increase the probability of the statement being true.
rand() % 1 == 0, true for every value from rand()
rand() % 2 == 0, true for every 2nd value from rand()
rand() % 3 == 0, true for every 3rd value from rand()
rand() % n == 0, true for every n:th value from rand()