The game Dungeons and Dragons introduces an element of chance using a 20-sided die. Sides are marked 1 to 20. When the d
Posted: Sat May 14, 2022 3:51 pm
The game Dungeons and Dragons introduces an element of chance
using a 20-sided die. Sides are marked 1 to 20. When the die is
thrown, the side it comes to rest on has the number that is
used.
a. Use rand( ) in a C++ expression that will have a random value
from 1 to 20.
b. Write a C++ function that returns a random number from 1 to
20.
c. When a program uses rand( ), a statement is used to make sure
that the program produces different random number each time it is
run. Write that statement.
d. Write the #include statements needed in a program that uses
rand( ) and the answer to 1.c.
using a 20-sided die. Sides are marked 1 to 20. When the die is
thrown, the side it comes to rest on has the number that is
used.
a. Use rand( ) in a C++ expression that will have a random value
from 1 to 20.
b. Write a C++ function that returns a random number from 1 to
20.
c. When a program uses rand( ), a statement is used to make sure
that the program produces different random number each time it is
run. Write that statement.
d. Write the #include statements needed in a program that uses
rand( ) and the answer to 1.c.