Advertisement
Felanpro

srand() function

Nov 4th, 2015
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. //Program uses time function to seed random number generator
  2. //and then generates random number
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     srand((unsigned)time(NULL));
  12.     int d=rand()%12;  
  13.     cout<<d;
  14.     system("pause");
  15.    
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement