#include <iostream> #include <cstdlib> // for rand() and srand() #include <ctime> int main() { // time function returns the number of seconds elapsed // since midnight, January 1, 1970. // srand will seed new sequence of pseudo-random numbers, // so that the numbers will be different every time we run. // (The initial seed is 1.) srand( (unsigned)time( 0 ) ); for(;;) { // rand returns an integer pseudo-random number std::cout << rand() % 10; std::cout << '\t'; } return 0; }