A beginner's question - Programmers Heaven

Howdy, Stranger!

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

Categories

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.