Question: Create a loop that roll a 1 2 sided dice 5 0 times. Using an array, count how many times each side is rolled. output

Create a loop that roll a 12 sided dice 50 times. Using an array, count how many times each side is rolled. output the results.
input none
output array results
start
SIDES =12
rolls[SIDES]=0,0,0,0,0,0
for(count =1; count <50; count++){
roll = random(0,5)
rolls[roll]++
}//end for
for(i =0; i < SIDES; i++){
output i +" rolled "+ rolls[i]+" times."
}//end for
end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!