jeudi 1 décembre 2016

Generating a random number between 2 and 100 inclusively in C

Any ideas on how to generate a random number between 2 and 100 in C Programming Language? I tried:

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

 int randomNums (int m, int n)
 {
    srand ((unsigned) time(NULL));  

    m = rand () % 99 + 2;
    n = rand () % 99 + 2;

    return m, n;

    }

But it doesn't seem to be working.




Aucun commentaire:

Enregistrer un commentaire