Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please, using C language, not C+or C++. Thanks. Homework 3 Files to submit: card

ID: 3600847 • Letter: P

Question

Please, using C language, not C+or C++. Thanks.

Homework 3 Files to submit: card_prob.c Time it took Matthew to Complete: 20 mins •

One thing I want to emphasize is that in this problem we are finding the actual probability not estimating through simulation. This means no need for random numbers.

All programs must compile without warnings when using the -Wall and -Werror options • Submit only the files requested Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc • Your program must match the output exactly to receive credit. Make sure that all prompts and output match mine exactly. Easiest way to do this is to copy and paste them • All input will be valid unless stated otherwise • Print all real numbers to two decimal places unless otherwise stated • The examples provided in the prompts do not represent all possible input you can receive. • All inputs in the examples in the prompt are underlined You don't have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program • If you have questions please post them on Piazza Restrictions • No global variables are allowed • Your main function may only declare variables, call other functions, and assign

For this example we are assuming

The size of the deck is 10 cards

Are initial hand size is 3.

There are 3 copies of the card we are looking for

X's in the example represent the card we want. O's are other cards

We will mulligan 2 cards

We want to draw the desired card by turn 2

Lines with --------------------- in the probability are steps that don't involve drawing cards

Initial Draw

Probability of not drawing the desired card in the initial draw: 7/10 * 6/9 * 5/8

Mulligan

Probability of not drawing desired card in the mulligan: 4/7 * 3/6

Drawing

Probability of not drawing the card during draw process is 4/7 * 3/6

The probability of not drawing at least 1 copy of the card we are looking for is Probability not drawing in initial hand * Probability not drawing in mulligan * Probability not drawing in during draw process. Filling in our numbers that is

(7/10 * 6/9 * 5/8) * (4/7 * 3/6) * (4/7 * 3/6)

And 1 minus the above is the probability of drawing at least 1 copy of the card by the desired turn

1 - (7/10 * 6/9 * 5/8) * (4/7 * 3/6) * (4/7 * 3/6)

Hand Deck Probability Description XXXOOOOOOO ----------- State at beginning O XXXOOOOOO 7/10 Draw first card OO XXXOOOOO 6/9 Draw second card OOO XXXOOOO 5/8 Draw third card

Explanation / Answer

#include #include #include using namespace std; int main() { srand(time(0)); // fCCounter = first choice counter, sCCounter = second choice counter int counter = 10000, fCCounter = 0, sCCounter = 0; // I run the simulation 10000 times for(int i = 0; i