Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ declaration error
#15
Russt Wrote:Shouldn't it be (rand() % (upperBound - lowerBound + 1))?

In that case the only way there'd be a division by 0 is if upperBound < lowerBound, which is tested against.

And it asks for an upperBound and lowerBound, then displays the instructions (what 1, 2, and 3 mean), then displays a guess before asking a number.

lowerBound = 25
upperBound = 75

rand() % (75 - 25 + 1)
rand() % (51)

So it will generate a number between 0 and 50 - not really what you want.
Reply


Messages In This Thread
C++ declaration error - by sky54264 - 2009-09-15, 12:35 PM
C++ declaration error - by Tempus - 2009-09-15, 12:56 PM
C++ declaration error - by Fiel - 2009-09-15, 01:02 PM
C++ declaration error - by sky54264 - 2009-09-15, 01:04 PM
C++ declaration error - by Tempus - 2009-09-15, 02:56 PM
C++ declaration error - by Fiel - 2009-09-15, 08:13 PM
C++ declaration error - by Takebacker - 2009-09-15, 08:35 PM
C++ declaration error - by Russt - 2009-09-15, 08:52 PM
C++ declaration error - by sky54264 - 2009-09-15, 08:56 PM
C++ declaration error - by Russt - 2009-09-15, 09:07 PM
C++ declaration error - by Fiel - 2009-09-15, 09:19 PM
C++ declaration error - by Russt - 2009-09-15, 10:15 PM
C++ declaration error - by sky54264 - 2009-09-15, 11:08 PM
C++ declaration error - by Russt - 2009-09-15, 11:35 PM
C++ declaration error - by Fiel - 2009-09-16, 09:30 AM
C++ declaration error - by sky54264 - 2009-09-16, 07:23 PM
C++ declaration error - by Russt - 2009-09-18, 08:22 PM
C++ declaration error - by Fiel - 2009-09-19, 05:05 PM

Forum Jump:


Users browsing this thread: