programming-examples/c/Numerical/C Program to Use rand and srand Functions.c
2019-11-15 12:59:38 +01:00

14 lines
326 B
C

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int num;
/* Seed number for rand() */
srand((unsigned int) time(0) + getpid());
printf("\nGenerating a random number using srand and rand function.\n");
num = rand();
printf("%d\n", num);
return EXIT_SUCCESS;
}