Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//We implement a function that simulates the outcome of tossing of 3 dice. //We will learn how to generate random numbers, and how to seed

//We implement a function that simulates the outcome of tossing of 3 dice. //We will learn how to generate random numbers, and how to seed a random number generator. //For example, we use the following code to generate a random number between 1 and 6. // rand() % 6 + 1 //The following code set the seed of the random number generator to 12345. // srand(12345);

#include #include #include

//TO DO //Implement a function named cum_prob below. //This function takes an integer k, and a long integer trials as inputs. //This function returns a double value. //In the fucntion, we toss the 3 dice multiple times. The number of tosses is trials. //We count the number of times that the outcomes of the 3 dice add up to at least k. ////And we then use this number and trials to calculate the probability that //the sum of the 3 dice is at least k. //Finally, we return this probablity.

int cum_prob()

//Do not change the following code. int main() { long n = 10000000; int k;

printf("Enter k :"); scanf("%d", &k); assert(k>= 3 && k<=18); srand(12345); printf("P(sum of the 3 dice is at least %d) = %.5lf ", k, cum_prob(k, n)); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions