Question looks a little weird I accept.
What I want to ask is this:
int main(){
srand(time(NULL));
for(int x=0;x<10000;x++){
int result = rand()%2;
if(result==0) cout << "Heads" << endl;
if(result==1) cout << "Tails" << endl;
return 0;
}}
So what I want to do is to simulate a huge amount of coin tosses. The output will look like this:
Heads
Heads
Heads
Tails
Heads
Tails
Tails
....
But I want a statement like
Total number of Heads= 4900, Tails= 5100 Longest Heads streak=7,Tails streak=8
at the top of the output. How can I do it? Since the loop involves cout
best I have been able to do is to place the statement at the bottom of output.
EDIT: I managed to solve the problem by using arrays. I first used a loop and simulated the tosses and record them by assigning them to array elements, and then printed them using another loop, in the order I need them. Thanks for all answers, upvoted them all.