Check out example codes for "comment générer un nombre aléatoire C++". It will help you in understanding the concepts better.

Code Example 1

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

int Rand( int a, int b)
{
       int nRand ;
       nRand= a + (int)((float)rand() * (b-a+1) / (RAND_MAX-1)) ;
       return nRand;
}

int main()
{
       int i;
       srand((unsigned)time(0));
       for (i=0; i<10; i++)
       {
               printf("nRand[%d]=%d\n",i,Rand(-100,100));
       }
       return 0;
}

Learn ReactJs, React Native from akashmittal.com