#include <iostream> #include <cstdlib> // for rand() and srand() #include <ctime> #include <algorithm> #include <iterator> // for std::ostream_iterator // frand returns pseudo-random numbers 0 to 9: int frand( int ) { return rand() % 10; } int main() { srand( (unsigned)time( 0 ) ); const int SIZE = 5; int dummy[ SIZE ]; // Populate array dummy with random numbers: std::transform( dummy, dummy + SIZE, dummy, frand ); // Display elements of dummy: std::copy( dummy, dummy + SIZE, std::ostream_iterator< int >( std::cout, "\t" ) ); return 0; }