Function name : srand
Header file : <stdlib.h>
Function prototype : void srand(unsigned seed);
Function : Generator used to initialize random numbers
Parameters : unsigned seed to set the seed of random time, its value is an integer
Return value : No return value
Program example: Use this function to generate different random integer sequences
#include<stdio.h>#include<stdlib.h>#include<time.h>intmain(void){inti;srand((unsigned)time(NULL));printf(Tworandomnumbersfrom0to99n);for(i= 0;i<5;i++){printf(%d,rand()%100);}putchar('n');return0;}
Running results
Tworandomnumbersfrom0to993719512261