Random number between two range

c++

Solution

You can generate a random `int` into a `float`, and then divide it by `RAND_MAX`, like this:

float a = rand(); // you can use qrand here
a /= RAND_MAX;

The result will be in the range from zero to one, inclusive.

Problem

rand() or qrand() functions generate a random int. ``` int a= rand(); ``` I want to get an random number between 0 and 1. How I can do this Work?

Original source