Ok so I'm working my way through a c++ book and as a project on my own I wanted to write a program to simulate the roll of a die 10 times. The only problem is when I run the program it will only roll the same number 10 times. Example if the program rolls a 5 it will roll 10 5 in a row, and I don't know why.
Here is the code.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main ()
{
int count = 0;
while (true)
{
count += 1;
if (count > 10)
break;
srand(time(0));
int RandomNumber = rand();
int die =(RandomNumber % 6) + 1;
cout << "You rolled a " << die << endl;
}
int exit; // I added this just as a way of running the program
cin >> exit; // and having it close when I give it the ok
return 0;