The way the function rand()
works is that every time you call it, it generates a random number. In your code, you've called it once and stored it into the variable random_x
. To get your desired random numbers instead of storing it into a variable, just call the function like this:
for (int t=0;t<10;t++)
{
cout << "\nRandom X = " << rand() % 100;
}