I'm having some trouble with this code:
for (long long int loop = 0; loop < 50000000; loop++)
{
srand( (unsigned)time(NULL) ); // set the seed
int r = abs(rand()); // stores the random seed for this loop
int res = loop + r - r * r / r; // random operations with the loop number and the random seed.
cout << "Loop number: " << loop << ". " << "Result: ";
cout << res << endl;
}//this was missing
If you run that code, you can see, very clearly in the console, that the output of it is only doing the calculations once every few seconds. What's going on? The number should be completely different for each loop, because it's doing calculations with random numbers. Instead, the number changes every x loops ran, and then it only seems to increase between these times it actually does the math.
Do I need to specify I want the loop to wait until everything is complete before moving on?