int main()
{
srand(time(NULL));
int r=rand();
}
The above function can generate any number, but what if I want to generate a number from a given set of values.
For example if I want to generate a number randomly but ONLY from the values 4,6,1,7,8,3
.
Is there any way to achieve this?
Any help would be appreciated.