Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions