# Quiz design with variables

I’m trying to make a quiz that has the following conditions

1. Answer must be in the range 1 - 9
2. A Random integer A greater than 0 but less than 10
3. A Random integer B greater than 0 but less than 10
4. An operator that can be either + or -
5. Basically the random integer A plus operator then random integer B should produce Answer

Basically, I cannot get events to satisfy all the above and make and show an equation

Any help will be appreciated. Thanks

I’m not sure what you mean. If the quiz answer is picked at random, it’s not a quiz anymore.

What I mean’t to say is I wanted a situation where only two integers are used with either + or - operators to get any answer between 1 and 9. Lets say 15 - 7 = 8 is valid but 22 - 7 is not because the answer is greater than 9. I need a random way to generate the numbers 15 and 7 to meet the condition answer

Well, if A is less than 10 and the operator is -, the total will be less than 10.
If A is more than 10 and the operator is -, B must be more than (A - 10).
If operator is + and total must be less than 10, A + B must be less than 10.
etc.

I think you need to decide the operator first, then you can generate possible values for A and B.

To translate the condition “must be less/more than”, you can use the While loop.
While A + B > 10, do Random(B), for instance. The loop will repeat until a satisfactory value is found.
If the game crashes or doesn’t load, it means your loop is not correct.

1 Like

Thanks for the tip. How do you create while loops in gdevelop?

It’s a special event, you’ll find it in the big + icon (top right of the screen).

Hi again. I managed to get the random questions working using “-” for now but I have a problem with getting the show Ans to show up. Please see the screenshot.
And how do I get the numbers to reset each time the correct answer is tapped