Question: #include #include #include #include #define SIZE 7 int main ( ) { srand ( time ( NULL ) ) ; / / seed random number

#include
#include
#include
#include
#define SIZE 7
int main(){
srand(time(NULL)); // seed random number generator
int frequency[SIZE]={0}; // initalize all frequnecy counts to 0
// roll the dice 60mil times
for(int roll =1; roll <=60000000; ++roll){
size_t face =1+ rand()%6;
++frequency[face]; // replaces entire switch of fig05_05 from sec 5.5
}
printf("%s%17s
", "Face", "Frequency");
// output frequency elements 1-6 in tabular format
for (size_t face =1; face < SIZE; ++face){
printf("%4zu%17d
", face, frequency[face]);
}
}
how does this C code work?

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!