Lee_assig18 - for(int i=1 i<=y i side=rand%2 if(side==0...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Cheu Lee Assig 18 #include<iostream> #include<cmath> #include<ctime> using namespace std; void tossingCoin(int); v int main() { int x; cout<<"How many times do you want to flip the coin?"<<endl; cin>>x; tossingCoin(x); return 0; } void tossingCoin(int y) { int side, H=0, T=0; srand(time(0));
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for (int i=1; i<=y; i++){ side=rand()%2; if (side==0){ cout<<"H"; H+=1; } if (side==1){ cout<<"T"; T+=1; } if (i%10==0) cout<<endl; } cout<<endl; cout<<"The total number of Heads is: "<<H<<endl; cout<<"The total number of Tails is: "<<T<<endl; }...
View Full Document

This note was uploaded on 05/16/2010 for the course CISCO EST61 taught by Professor Miller during the Spring '10 term at Fresno City College.

Ask a homework question - tutors are online