Check whether a random number is even or odd using the remainder.

This tutorial is part of the Nairda learning path. You can build it step by step inside the app, which checks every block you place before letting you move on.


The steps

  1. We add a While loop, which repeats forever.
  2. We create a number variable called number and a text one called text.
  3. Above the loop we set number to a random value from 0 to 10.
  4. Behind it we add an If with a comparison in its condition.
  5. Inside the comparison we put an operation and choose the remainder.
  6. It takes the remainder of number divided by 2.
  7. If the remainder is 0 the number is even, so we write Is even.
  8. We add a second If with its own comparison.
  9. This one also gets an operation set to the remainder.
  10. And it also divides number by 2.
  11. If it is not 0 the number is odd, so we write Is odd.
  12. On the dashboard we draw a label and name it Result:
  13. And we drag the variable text onto the label.

When you finish, the app takes you straight to the next tutorial in the path.

Build it in Nairda