Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- using namespace std;
- int flip(void);
- int main(){
- int ans=0;
- srand(time(NULL));
- for(int i=1;i<=100;i++)
- {
- if(flip()==1)
- {
- ans++;
- cout<<"Heads ";
- }
- else if(flip()==0)
- cout<<"Tails ";
- }
- printf("\n\nThe total number of Heads was %d\n",ans);
- printf("The total number of Tails was %d\n",100-ans);
- }
- int flip(void){
- int a;
- a = rand()%2;
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement