>>how to rand between three integer num1 num2 num 3

You say in between the three integers. That means one of the numbers, either num1, num2 or num3 has to be a min or the max. Which means the last one has to fall in between. Thus this implies that you want a number in the range of , [ min(num1,num2,num3) to max(num1,num2,num3) ]; So a general formula is rand() % (max - min ) + min , or min + (max-min) * (rand()/(float(RAND_MAX+1))