+ 1

How to genrate random no with in a range..???

As like 10-1500 it produce 86,69,72,178,1402....

21st Jul 2019, 8:26 AM
Akshay Sharma
Akshay Sharma - avatar
3 Answers
+ 3
if c++ has a random function (lets call it rand) which produces numbers between 0-1 then you could do: //range 10-1500 int r = rand() * 1490 + 10; //range a-b int r = rand() * (b-a) + a;
21st Jul 2019, 8:29 AM
Anton Böhler
Anton Böhler - avatar
+ 2
Please help
21st Jul 2019, 8:26 AM
Akshay Sharma
Akshay Sharma - avatar
+ 1
Thanks bro for help
21st Jul 2019, 8:29 AM
Akshay Sharma
Akshay Sharma - avatar