Closed enusbaum closed 11 months ago
Verified against Borland C++ 4.5
Compiled the following using bcc rand.cpp
:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main() {
// Seed the random number generator
srand(1234);
// Generate and output the next three random numbers
for (int i = 0; i < 10; ++i) {
int randomNum = rand();
printf("Random number %d: %d\n", (i + 1), randomNum);
}
return 0;
}
Output Results:
Unit Tests for rand()
are verified against this list
Verified it's the same stdlib routine embedded within majorbbs.exe
:
srand()
to set seed in memoryrand()
from using internal C# RNG to ported Borland C++ routine