Question: Given the code below ( a flip function that randomly returns a 1 or 0 when called), write a C program that prompts the user

Given the code below ( a "flip" function that randomly returns a 1 or 0 when called), write a C program that prompts the user for the number for times the user wants to flip a coin. Your program will flip a virtual coin that number of times and return the following:

1. The number of times heads occurred.

2. The number of times tails occured.

Code:

// Write a program which prompts the user for the number of coin flips, // and prints the number of heads and tails for the sequence of flips. // A flip() function is provided which randomly returns 1 or 0.

#include // Standard I/O library #include // Standard library of C commands

int flip(); // Prototype for flip function below

int main() { // Declare some variables // Prompt the user for the number of times to flip the coin // Flip the coin that number of times, keeping track of heads and/or tails // Print the results: number of flips, and number of heads and tails

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!