Prelude to programing sixth edition chapter 6 short answer
Prelude to programing sixth edition - chapter 6 - short answer question number 16 on page 401. If Number = 6, give the range of possible integers produced by the following expressions: A. Floor(Random() * Number) B. Floor(Random() * Number) + 3 C. Floor(Random() * Number +3))
Solution
Since Random() will generate numbers between 0(including) to 1(excluding).
Floor will return greatest integral value less than the number
a) Hence Floor(Random() * Number) will return values between 0 to 5 Inclusive
b) Floor(Random() * Number) + 3 will return values between 3 to 8 Inclusive
c) Floor(Random() * Number +3)) will return only 3 value for any Random Number Generated
