Question: The code below is written to count the number of successes for 1-6 number of eyes when rolling a dice a great number of time.

The code below is written to count the number of successes for 1-6 number of eyes when rolling a dice a great number of time. A user gives an input of 10 000 and the result seems to be correct at a first glance: 1-1624 2-1624 3-16234-1625 5-1622 6-1625 But the sum is 9743 and it should be 10000. Find the mistake in the code and explain why the result is not correct. nbrRolls = input ('Please give the number of rolls (min 10 000): '); % For counting the number of rolls per result i.e. 1-6. counter = zeros (1, 6); for roll-1:nbrRolls end counter (rand! (6) ) = counter (randi (6) ) + 1; The code below is written to count the number of successes for 1-6 number of eyes when rolling a dice a great number of time. A user gives an input of 10 000 and the result seems to be correct at a first glance: 1-1624 2-1624 3-16234-1625 5-1622 6-1625 But the sum is 9743 and it should be 10000. Find the mistake in the code and explain why the result is not correct. nbrRolls = input ('Please give the number of rolls (min 10 000): '); % For counting the number of rolls per result i.e. 1-6. counter = zeros (1, 6); for roll-1:nbrRolls end counter (rand! (6) ) = counter (randi (6) ) + 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
