C library function - rand()

PHOTO EMBED

Sat Mar 05 2022 06:58:46 GMT+0000 (Coordinated Universal Time)

Saved by @danihf23 #c

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

int main () {
   int i, n;
   time_t t;
   
   n = 5;
   
   /* Intializes random number generator */
   srand((unsigned) time(&t));

   /* Print 5 random numbers from 0 to 49 */
   for( i = 0 ; i < n ; i++ ) {
      printf("%d\n", rand() % 50);
   }
   
   return(0);
}
content_copyCOPY

https://www.tutorialspoint.com/c_standard_library/c_function_rand.htm