Object Oriented Programming

1:

Assume that the random number generating function - rand( ), returns an integer between 0 and 10000 (both inclusive). If you want to simulate the throwing of a die using this random function, use the expression     

A.

rand ( ) % 6

B.

rand ( ) % 6 + 1

C.

rand ( ) % 5 + 1

D.

none of the above

 

Answer : B

Explanation :

It should randomly generate any integer between 1 and 6. rand( ) % 6 returns an integer from 0 to 5. To make it 1 to 6, we need to add 1

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.