chapter5
This commit is contained in:
20
DeitelC/Chapter5/coinTossing.c
Normal file
20
DeitelC/Chapter5/coinTossing.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include "flip.h"
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
int heads = 0, tails = 0;
|
||||
for(int i = 0; i < 100; i++){
|
||||
if(flip()) {
|
||||
heads++;
|
||||
} else {
|
||||
tails++;
|
||||
}
|
||||
}
|
||||
printf("%s%d%s%d\n", "Heads: ", heads, ", Tails: ", tails);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user