0

is it rand() or rand(x)?

We have declared the variable as x and applied the constraints to it. Then is it rand() or rand(x)?

20th Dec 2017, 7:30 PM
Harsha Leo
Harsha Leo - avatar
2 Respostas
+ 2
To apply constraints to rand, we do : rand()%x; // Rand accepts no argument. Which returns a number in the range 0 to x-1. To get a number in range L -> U, you do : L + (rand()%(U-L+1)); This returns a number in the range L to U, both L and U included as the possible outcome.
21st Dec 2017, 1:17 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
thanks bro
21st Dec 2017, 3:22 PM
Harsha Leo
Harsha Leo - avatar