
-----------------------------------
snozking
Tue Mar 22, 2022 10:36 am

Randomly select an equation expression (Turing)
-----------------------------------
i want to write a code to randomly select from * / + and -.

how can i do that in turing?

thankyou :canada:

-----------------------------------
scholarlytutor
Tue Mar 22, 2022 4:08 pm

RE:Randomly select an equation expression (Turing)
-----------------------------------
Hi snozking,

So first you'll need two variables to store your left and right numbers. You also need one more integer variable to store your random number (call it RandomNumber)

Then, there's a procedure called randint. It works like this:

randint(RandomNumber, 1, 4)

Your variable now has a random number inside of it between 1 and 4.

Finally, you need an if block to check which number you got. It will work something like this:

if RandomNumber = 1 then
put LeftNumber, " + ", RightNumber
elsif RandomNumber = 2 then...

and I'll let you try to figure out the rest.

Hope that helps. Feel free to post your code here if you're still having trouble.
