In C programming In a main function declare an array of 1000 ints. Fill up the array with random numbers that represent the rolls of a die. That means values from 1 to 6. Write a loop that will count how many times each of the values appears in the array of 1000 die rolls. Use an array of 6 elements to keep track of the counts, as opposed to 6 individual variables. Print out how many times each value appears in the array. 1 occurs XXX times 2 occurs XXX times Hint: If you find yourself repeating the same line of code you need to use a loop. If you declare several variables that are almost the same, maybe you need to use an array. count1, count2, count3, count4, … is wrong. Make an array and use the elements of the array as counters. Output the results using a loop with one printf statement. This gets more important when we are rolling 2 dice.
In C programming
In a main function declare an array of 1000 ints.
Fill up the array with random numbers that represent the rolls of a die. That means values from 1 to 6.
Write a loop that will count how many times each of the values appears in the array of 1000 die rolls.
Use an array of 6 elements to keep track of the counts, as opposed to 6 individual variables.
Print out how many times each value appears in the array.
1 occurs XXX times
2 occurs XXX times
Hint: If you find yourself repeating the same line of code you need to use a loop. If you declare several variables that are almost the same, maybe you need to use an array. count1, count2, count3, count4, … is wrong. Make an array and use the elements of the array as counters. Output the results using a loop with one printf statement. This gets more important when we are rolling 2 dice.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images