Qbasic

Moderators: None (Apply to moderate this forum)
Number of threads: 81
Number of posts: 235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
A beginner's question Posted by TehDude on 18 Jun 2007 at 4:07 AM
Hello, I have been working with qBasic for a while now, and now I need a little help with the RANDOMIZE TIMER command.

Let's say, I make my program throw 2 or more dices (Print random numbers from 1 to 6 two times) and make it throw the "dices" until both of the numbers are equal, so, I've gotten to that part, but now I must make the program tell me how many times were the dices thrown until the numbers were equal.

So, could you please, tell me the operator for that?

Thank you :)
Report
Re: A beginner's question Posted by zibadian on 18 Jun 2007 at 4:37 AM
: Hello, I have been working with qBasic for a while now, and now I
: need a little help with the RANDOMIZE TIMER command.
:
: Let's say, I make my program throw 2 or more dices (Print random
: numbers from 1 to 6 two times) and make it throw the "dices" until
: both of the numbers are equal, so, I've gotten to that part, but now
: I must make the program tell me how many times were the dices thrown
: until the numbers were equal.
:
: So, could you please, tell me the operator for that?
:
: Thank you :)
:
First throw 1 die and set a counter to 0. Then make a loop, which throws the other die and increases the counter. The loop should end if the second die is equal to the first. In psuedocode:
  first = roll die
  counter = 0
  repeat
    second = roll die
    increase counter
  until first = second
  show counter



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.