So I have a project for my class where I have to make a simulated craps game run 1000 times and display the number of wins and losses. I ran into a problem that I cannot seem to solve where the game runs but has the same numbers for the rolling of the dice. I tried a few things like putting it in a while loop (it was in a for loop before) as apparently for loops do not reset the variables. I tried to "reset" the variable by making it equal to 0 at the beginning of the loop. However this didn't work and any help is appreciated (I'm new and messy when programming, sorry).
int onek (void){
int total = 0;
int wins = 0;
int count = 0;
while(count <= 1000) {
srand(time(NULL));
int ad = 1 + rand() % 6;
int bd = 1 + rand() % 6;
int point = ad + bd;
cout << ad << " " << bd << " " << point << " "
<< wins << " "<< total << endl;
if (point == 7 || point == 11) {
cout << "Win!" << endl;
total += 1;
wins += 1;
} else if (point == 2 || point == 3 || point == 12) {
cout << "Loss." << endl;
total += 1;
} else {
int od = 1 + rand() % 6;
int td = 1 + rand() % 6;
int sum = od + td;
if (sum == point) {
cout << "Win!" << endl;
wins += 1;
total += 1;
} else if (sum == 7) {
cout << "Loss." << endl;
total += 1;
}
}
count++;
}
cout << endl << endl << endl << endl << endl
<< "Total wins: " << wins << "\nTotal losses: "
<< total - wins;
cout << "\nTotal Games: " << total;
}