View unanswered posts | View active topics It is currently Thu Aug 16, 2018 4:21 pm

Reply to topic  [ 2 posts ] 
Random number generator 
Author Message

Joined: Thu Jan 05, 2012 11:07 am
Posts: 1
Post Random number generator
I would like to like to create a random number generator in RobotC. What is the best way?

Thu Jan 05, 2012 11:12 am
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Random number generator
First find out what kind of random number generator you are looking for. If you're happy to use the built in one, you could do something like this:
task main () {
  writeDebugStreamLine("%d", random[10]);  // number between 0 and 9
  writeDebugStreamLine("%d", random[10000]); // number between 0 and 9999

- Xander

| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Thu Jan 05, 2012 12:43 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.