Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Rand Int
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
cam




PostPosted: Sun Jan 21, 2007 2:18 pm   Post subject: Rand Int

Why doesn't this work?


Rand.Int (1, 6)
if Rand.Int (1) then
put "haha"
end if
Sponsor
Sponsor
Sponsor
sponsor
lord_pwnerer




PostPosted: Sun Jan 21, 2007 3:00 pm   Post subject: Re: Rand Int

code:
var number : int

randint(number,1,6)

if number = 1 then
put"haha the number = 1"
end if


Use randint instead of Rand.Int... When you use randint you can assign a variable to the number, then check what that variable was set to.

EDIT: By the way, the reason that it doesn't work is when you wrote Rand.Int the second time, it was just like calling the procedure a second time, not checking to see what the random number was. (sorry if this doesn't make any sense, I'm in a rush)
Robert




PostPosted: Sun Jan 21, 2007 3:05 pm   Post subject: RE:Rand Int

Rand.Int is a function...

code:

if Rand.Int(1,6) = 1 then
     put "haha"
end if


Always use Rand.Int instead of randint
cam




PostPosted: Sun Jan 21, 2007 3:37 pm   Post subject: Re: Rand Int

o thx very much
Cervantes




PostPosted: Sun Jan 21, 2007 7:37 pm   Post subject: Re: Rand Int

lord_pwnerer @ Sun Jan 21, 2007 3:00 pm wrote:

Use randint instead of Rand.Int... When you use randint you can assign a variable to the number, then check what that variable was set to.


Please, don't say this. It's fantastically wrong. It's so wrong, we've even got a mini tutorial to explain it. Read it, and learn!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: