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();

3 thought on “How to generate random numbers in C”

Leave a Reply