| Date of Quiz: | Tue Nov-7 |
Note: This is a programming quiz. You must use Visual C++. You must begin with a new project, and you may not use any notes or any pre-written code.
Your task is to write the missing functions in the code below: rand1(), random(), coinFlip(), and main().
// Quiz7.cppSee Course Home Page.#include <stdio.h>
#include <iostream.h>
#include <stdlib.h> // for rand()
#include <time.h> // for time()
// rand1() returns a random floating point number
// in the range [0,1]. It uses the built-in function
// rand().double rand1()
{
// YOU WRITE THIS CODE
}
// This function returns a random floating point
// number in the range [lo,hi]. It uses the
// function rand1() defined above.double random(double lo, double hi)
{
// YOU WRITE THIS CODE
}
const int HEADS = 0;
const int TAILS = 1;// This function returns HEADS or TAILS by simulating
// one coin flip. It uses one of the random functions
// from above.int coinFlip()
{
// YOU WRITE THIS CODE
}
// Write this main function so that it has the following
// behavior (where *3* indicates user input the number 3):
//
// How many more heads than tails should I wait for: *3*
// It took 17 coin flips before there were 3 more heads
// than tails.
// Goodbye!void main()
{
// YOU WRITE THIS CODE
}