Coin Flip Game

In Ics 212, I created a coin flip game. First, the program would ask the user to guess whether the outcome of a coin flip will be heads or tails. Where ‘0’ represents heads and ‘1’ represents tails. In this program, It also generates a random number (0 or 1) to simulate the coin flip. It then compares the user’s guess to the result of the coin flip to determine if the guess was correct. If the user guessed correctly it would win the game.

In this program, I learned how to generate random numbers. The most important aspect of this program is the generation of random numbers, which is accomplished by using the rand() function. This function is a cornerstone in C programming for generating pseudo-random numbers. It enhances the randomness of each coin flip. The random number generator uses the current time as a seed with srand(time(NULL)). This program effectively mimics the unpredictability of a real coin flip.