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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started