adplus-dvertising
frame-decoration

Question

Which of the following formulas can be used to generate random integers between 1 and 10?

a.

1 + rand() % (10 - 1 + 1)

b.

1 + (10 - 1 + 1) % rand()

c.

10 + rand() % (10 - 1 + 1)

d.

10 + rand() % (10 + 1)

Answer: (a).1 + rand() % (10 - 1 + 1)

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following formulas can be used to generate random integers between 1 and 10?