QUESTION

Text
Image

# 6.23 LAB: Flip a coin Define a function named CoinFlip that returns "Heads" or "Tails" according to a random value 1 or 0 . Assume the value 1 represents "Heads" and 0 represents "Tails". Then, write a main program that reads the desired number of coin flips as an input, calls function CoinFlip 0 repeatedly according to the number of coin flips, and outputs the results. Assume the input is a value greater than 0 . Hint: Use the modulo operator (\%) to limit the random integers to 0 and 1. Ex: If the random seed value is 2 and the input is: 3 the output is: Tails Heads Tails Note: For testing purposes, a pseudo-random number generator with a fixed seed value is used in the program. The program uses a seed value of 2 during development, but when submitted, a different seed value may be used for each test case. The program must define and call the following function: string CoinFlip() 349694.2098844.qx3zqy7\begin{tabular}{l|l} LAB & 6.23.1: LAB: Flip a coin \end{tabular} $0 / 10$ main.cpp Load default template... $\begin{array}{ll}1 & \text { \#include 〈iostream> } \\ 2 & \text { \#include 〈cstdlib> } \\ 3 & \text { using namespace std; } \\ 4 & \\ 5 & / * \text { Define your function here */ } \\ 6 & \\ 7 & \text { int main() }\{ \\ 8 & / / \text { Add more variables as needed } \\ 9 & \\ 10 & \text { srand(2); // Unique seed } \\ 11 & \\ 12 & /{ }^{*} \text { Type your code here */ } \\ 13 & \\ 14 & \text { return } 0 ; \\ 15 & \\ 16 & \end{array}$ 1 \#include 〈iostream> 2 \#include 〈cstdlib〉 using namespace std; /* Define your function here */ int main( ) \{ // Add more variables as needed srand(2); // Unique seed $I^{*}$ Type your code here */ return $\theta$; 子  