you can simply generate a random number by the function rand() in the stdlib directory. However c++ can't generate true random numbers as they are pseudo-random means having some pattern so we need to seed them for this we use the function srand(), and we must give a seeding-number in the argument so we usually give it the time as argument, like this
srand(time(0));

now if you want to give a range you can do it by this syntax

(minimum+rand())%maximum;
for example if you want to generate the numbers between 1 and 10,000 simply do it this way

(1+rand())%10000;

so the complete code should be like this along with a function to do it :
--------------------------------

#include <iostream.h>
#include <stdlib.h>
int generate(int,int); //prototype for function
main(){
srand(time(0)); // Seed the random function
int min=1,max=10000; // variable to store max and min range
int number=generate(min,max);
cout << "The generated number is : "<<number;
}
int generate(int min,int max){
int num=(min+rand())%max;
return num;
}

-----------------------------------

You can alter the range by altering the min and max variables

this is what the linux man pages say (in part) about rand(3):

" ... The versions of rand() and srand() in the Linux C Library
use the same random number generator as random() and sran dom(), so the lower-order bits should be as random as the
higher-order bits. However, on older rand() implementa
tions, the lower-order bits are much less random than the
higher-order bits.

In NumericalRecipesinC:TheArtofScientificComputing
(William H. Press, Brian P. Flannery, Saul A. Teukolsky,
William T. Vetterling; New York: Cambridge University
Press, 1992 (2nd ed., p. 277)), the following comments are
made: "If you want to generate a random integer between 1
and 10, you should always do it by using high-order
bits, as in

j=1+(int) (10.0*rand()/(RAND_MAX+1.0));

and never by anything resembling

j=1+(rand() % 10);

(which uses lower-order bits)."

Random-number generation is a complex topic. The Numeri calRecipesinC book (see reference above) provides an
excellent discussion of practical random-number generation
issues in Chapter 7 (Random Numbers). ..."

Now we have all seen that our moderators are less than perfect:

// typical example for seeded random integers in a given range
#include <stdlib.h>
#include <stdio.h>
#include <time.h> // time()
int main(void)
{
int i, min, max, rn;
srand(time(NULL)); // random seed on most compilers
min = 1;
max = 10000;
printf("Ten random numbers from 1 to 10000\n\n");
for(i = 0; i < 10; i++)
{
rn = min + (int)((float)max*rand()/(RAND_MAX+(float)min));
printf("%d\n", rn);
}
return 0;
}

I am having a trouble not knowing how to do a java code that will take user string then encrypt it using Elgamal algorithm as following
Elgamal algorithm Pseudo code: ...

A few weeks ago my laptop browsing and windows apps error. When i am on my facebook account i can watch youtube videos posted on feeds but other videos pos ...