Random by time : Random « Development « C++






Random by time

  
#include <iostream>
#include <ctime>
using namespace std;

int main( void )
{
 int i,j;
 srand( (unsigned)time( NULL ) );
 /* Display 10 numbers. */
 for( i = 0;i < 10;i++ )
 {
   j= rand();
   cout << j << endl;
     }
}
  
    
  








Related examples in the same category

1.Rand functionRand function
2.Outputs 20 random numbers from 1 to 100.Outputs 20 random numbers from 1 to 100.