IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
Earn Free Bitcoin
CData Types & Operators ❯ Random Numbers
<02.07>
/* The random [rand()] function */
#include <stdio.h> #include <time.h> #include <stdlib.h> int main (void) { /* initialize random generator */ srand (time(NULL)); /* generate random numbers */ printf("RAND_MAX = %d\n", RAND_MAX); printf ("A number between 0 and RAND_MAX : %d\n", rand()); printf ("A number between 0 and 99: %d\n", rand() % 100); printf ("A number between 0 and 9: %d\n", rand() % 10); printf ("A number between 1 and 6: %d\n", (rand() % 6) + 1); return (0); }
Hergestellt in Deutschland / Made in Germany
RAND_MAX = 32767 A number between 0 and RAND_MAX : 10746 A number between 0 and 99: 43 A number between 0 and 9: 8 A number between 1 and 6: 2
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.