Search This Blog

Saturday, December 31, 2011

How to generate a random number in C?

#include 
#include 

srand(time(NULL));
int r = rand();
 
 
/* random int between 0 and 19 */
int r = rand() % 20;
 

No comments:

Post a Comment

Thank you