Page 1 of 1

Write a C++ program named "coin.cpp" that simulates flipping a coin repeatedly and continues until three consecutive hea

Posted: Fri Jul 08, 2022 6:15 am
by answerhappygod
Write a C++ program named "coin.cpp" that simulatesflipping a coin repeatedly and continues until three consecutiveheads are tossed. At that point, your program should display thetotal number of coin flips that were made. Use rand() function tosimulate random toss of the coin. Here are a few example runs ofthe program:
Sample run 1
Head
Tail
Tail
Head
Head
Tail
Head
Tail
Head
Head
Head
It took 11 flips to get 3 consecutive heads.
Sample run 2
Tail
Head
Tail
Tail
Tail
Tail
Head
Head
Tail
Head
Tail
Head
Head
Tail
Tail
Head
Head
Head
It took 18 flips to get 3 consecutive heads.
About Random Number Generation