Functions Q.11

  • Option : D
  • Explanation : An example will help you understand. Let a be 6 and b be 10. There are 5 numbers between 6 to 10 (both inclusive). This is b-a+ 1 (10 - 6 + 1). rand( ) % (b - a + 1) returns an integer from 0 to (b - a). To make it a to b, add a, giving rand() % (b-a+ 1) + a.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *