Can anyone explain what this block does?

cout << "This program will print a random number." << endl;
srand((unsigned)time(0));
int rnum = (rand()%10) + 1;
cout << "\nGenerated random number: " << rnum << endl;
_getch();
return 0;

I understand it states that it prints a random number, but what I want to know is *how* it does it. I've never really seen srand used that way. I see they are declaring integer rnum for random number, followed by a rand statement that I do not understand.

Any help would be appreciated.
First, the srand() and rand() have been deprecated, so one should shift to use:
http://www.cplusplus.com/reference/random/


However, to decipher the old code, read:
http://www.cplusplus.com/reference/cstdlib/srand/
http://www.cplusplus.com/reference/cstdlib/rand/
Topic archived. No new replies allowed.