1) Write two functions that roll two dice. The dice should be a 20-sided dice (AKA: d20 - has an icosahedron shape) and a 4-sided dice (d4 - tetrahedron). 2) In the main() function, call the two functions in a loop and roll the dice until both die roll a 1 ("snake eyes"). 3) Keep track of the number of loop executions with a counter variable and, once snake eyes has been achieved, print the count outside of the loop. Theoretically, the probability of this occurring is (1/4) * (1/20). You might be interested to run this program a few times and see if the roll count tends toward 80. NOTE: You can use srand(time(0)) along with #include to ensure random rolls and different results for every program execution.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
I need help figuring out this
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images