+ 3
What has possibly gone Wrong?
Please see my code - What is Incorrect?? How?? Why??? for relevant details... Please Help...
11 Answers
+ 12
rand()%upper returns a random number in 0 to (upper-1). You are adding low (25) to it thereby resulting in out of range numbers.
+ 11
@Kinshuk : If range is 25-30, you have to use (25 + (rand()%5)). But you are using (25 + (rand()%30)).
+ 7
@Luka
???
I had set the range to 25-30, as the format is :
lower_limit+(rand()%upper_limit)
+ 7
And Thank You , Luka
+ 6
@Krishna Teja Yeluripati
But sir, lower is added to get range of lower->upper-1?
Its there in the c++ tutorial?!
+ 6
So we have to mod rand() with the difference of upper and lower?
They haven' explained this on the tutorial at least...
+ 6
Thank You, Sir
+ 6
Why haven't they explained much about limits?
This is even wrong in the C++ Book i have and on a few sites...
+ 6
Guess it will be better to use random()...
+ 5
Please Help?!!!
+ 3
You are the experts!
You tell me what is going on!
I am unable to see any error...