In C, we can use the rand function to generate random numbers.
The generated random number is between 0 and RAND_MAX values.
/*
Example: Genrate a random number in C language
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char const *argv[]) {
srand(time(NULL));
int num = rand();
printf("Generated random number: %d\n",num);
printf("the value of RAND_MAX: %d",RAND_MAX);
return(0);
}Source:www.lautturi.comexample of output:
Generated random number: 25059 the value of RAND_MAX: 32767