Need Help

I need the program to allow the user to specify (via keyboard data entry) the number of coin tosses to perform.
When you run the program, and it should say the result of each coin toss (that is, "Heads" or "Tails"). I am stuck!
These are the instructions

Call srand
Prompt the user to enter how many coin tosses to perform
Input and store the user's selection
Create a counter and set it to zero
Start the loop here
If the counter equals the number of tosses to perform
Break from the loop
Get and store a randomly-generated number in the range 0 to 1
If the randomly-generated number equals 0
Output "heads"
If the randomly-generated number equals 1
Output "tails"
Add one to the counter
Loop back from here

This is what I am working with.

#include <ctime>
#include <cstdlib>
#include <iostream>

using namespace std;

int main()

{
srand (time (0));
int x;
x = rand() % 2;

if (x == 1)
{
cout << "Heads" << x << endl;
}
else
{
cout << "Tails" << x << endl;
}
system ("pause");
return 0;
}
Prompt the user to enter how many coin tosses to perform

http://www.cplusplus.com/doc/tutorial/basic_io/

Input and store the user's selection

http://www.cplusplus.com/doc/tutorial/basic_io/

Create a counter and set it to zero

http://www.cplusplus.com/doc/tutorial/variables/

Start the loop here

http://www.cplusplus.com/doc/tutorial/control/

If the counter equals the number of tosses to perform
http://www.cplusplus.com/doc/tutorial/control/

Break from the loop

http://www.cplusplus.com/doc/tutorial/control/


Topic archived. No new replies allowed.