Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

A beginner's question

TehDudeTehDude Posts: 1Member
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 :)

Comments

  • zibadianzibadian Posts: 6,349Member
    : 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:
    [code]
    first = roll die
    counter = 0
    repeat
    second = roll die
    increase counter
    until first = second
    show counter
    [/code]
Sign In or Register to comment.