Hello Guys, I need help to my program on C.
I want to create a Coinflip Simulation that count how often a coin to need flipp until 3 times the same (head or tale) in a row.
Thats what i had already:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int kopf = 1; // "kopf" is head
int zahl = 0; // "zahl" is tale
int variable;
int ergebnis = 0;
int i;
int main() {
time_t t;
srand(time(&t));
for(i = 0; i < 10; i++) {
ergebnis = ("%d ", rand() % 2);
if (ergebnis == 1) {
printf("K "); //"K" is for head
}
if (ergebnis == 0) {
printf("Z "); //"Z" is for tale
}
}
}
I think the black 10 have to exchange with a variable thats know exectly when 3 times are tail or 3 time are head.
But i dont know how can i make this.