How to generate random numbers in C

To generate a random number in C you can use the snippet below.

Sample C

#include <time.h>
#include <stdlib.h>

srand(time(NULL));
int r = rand();

Please Share us:
Please rate this snippet

3 thoughts on “How to generate random numbers in C

Leave a Reply