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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr