srand()

Prototype: void srand(unsigned int seed);
Header File: stdlib.h (C) or cstdlib (C++)
Explanation: Srand will seed the random number generator to prevent random numbers from being the same every time the program is executed and to allow more pseudorandomness.



Example:
//Program uses time function to seed random number generator
//and then generates random number
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
    srand((unsigned)time(NULL)); 
    int d=rand()%12;  
    cout<<d;
}
Other Functions