Vidyalelo
Data Structure · Q357

Miscellaneous on Data Structures

Programming · Data Structure · question 357

Q357

hat is the correct formula for generating random numbers in the range (lower,upper) using rand()?

A.
rand() % (upper - lower)
B.
rand() + lower
C.
(rand()%(upper-lower)) + lower
D.
(rand()%(upper-lower+1)) + lower
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board