0

how do I generate random numbers from 1 to 36 including 00?

5th Sep 2017, 7:18 PM
Raul Cabeza
Raul Cabeza - avatar
2 Réponses
+ 2
use rand()
5th Sep 2017, 8:20 PM
mhadi ahmed
mhadi ahmed - avatar
+ 2
/* rand example */ #include <stdio.h> #include <stdlib.h> #include <time.h> int main () { int iSecret, iGuess; srand (time(NULL)); iSecret = rand() % 10 + 1; do { printf ("Guess the number (1 to 10): "); scanf ("%d",&iGuess); if (iSecret<iGuess) puts ("The secret number is lower"); else if (iSecret>iGuess) puts ("The secret number is higher"); } while (iSecret!=iGuess); puts ("Congratulations!"); return 0; }
5th Sep 2017, 8:21 PM
mhadi ahmed
mhadi ahmed - avatar