include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
// 1. Put Function Prototype for coin toss here
// 2. Put prototype for Guess here
int main()
{
int numTosses;// To hold the number of tosses
//3. put a call to the void function Guess here
// 4. Write a c++ stmt that asks the user how many coin tosses they //want to make.
// 5. write a c++ statement that reads the number of coint tosses //desired by the
//user into the variable numTosses
// 6. write a loop that calls the coin toss function however many //times the user has
// chosen (this number was stored in the numTosses variable in 3 //above
return 0;
}
// The coinToss function simulates the toss
// of a coin. It displays either "heads" or
// "tails".
void coinToss()
{
// Get the system time so we can use it
// to seed the random number generator.
unsigned seed = time(0);
// Use the seed value to seed the random
// number generator.
srand(seed);
// Generate a random number in the range
// of 1 through 2.
int number = 1 + rand() % 2;
// Display either "heads" or "tails".
if (number == 1){
cout << "heads\n";
}
else {
cout << "tails\n";
}
}
// 7. write a void function called Guess that prints the message:
//What do you think will come up most? heads or tails.
//followed by a triangle of stars - see output for an example
***************************************************************************************
the questions are on //
where it has
// 7. write a void function called Guess that prints the message:
//What do you think will come up most? heads or tails.
//followed by a triangle of stars - see output for an example
void Guess()
{
cout << " What do you think will come up most? heads or tails?" << endl;
cout << "*\n" << endl;
cout << "**\n" << endl;
cout << "***\n" << endl;
cout << "***\n" << endl;
}
}
by the way the is my answer on the last problem so not sure.
#include <cstdlib>
#include <ctime>
using namespace std;
// 1. Put Function Prototype for coin toss here
// 2. Put prototype for Guess here
int main()
{
int numTosses;// To hold the number of tosses
//3. put a call to the void function Guess here
// 4. Write a c++ stmt that asks the user how many coin tosses they //want to make.
// 5. write a c++ statement that reads the number of coint tosses //desired by the
//user into the variable numTosses
// 6. write a loop that calls the coin toss function however many //times the user has
// chosen (this number was stored in the numTosses variable in 3 //above
return 0;
}
// The coinToss function simulates the toss
// of a coin. It displays either "heads" or
// "tails".
void coinToss()
{
// Get the system time so we can use it
// to seed the random number generator.
unsigned seed = time(0);
// Use the seed value to seed the random
// number generator.
srand(seed);
// Generate a random number in the range
// of 1 through 2.
int number = 1 + rand() % 2;
// Display either "heads" or "tails".
if (number == 1){
cout << "heads\n";
}
else {
cout << "tails\n";
}
}
// 7. write a void function called Guess that prints the message:
//What do you think will come up most? heads or tails.
//followed by a triangle of stars - see output for an example
***************************************************************************************
the questions are on //
where it has
// 7. write a void function called Guess that prints the message:
//What do you think will come up most? heads or tails.
//followed by a triangle of stars - see output for an example
void Guess()
{
cout << " What do you think will come up most? heads or tails?" << endl;
cout << "*\n" << endl;
cout << "**\n" << endl;
cout << "***\n" << endl;
cout << "***\n" << endl;
}
}
by the way the is my answer on the last problem so not sure.