Small Steps I — Creating with Text and Numbers

Remembering true and false

Change is_ready to false and check how the output changes.

What you will learn

bool is a type that stores true or false. It remembers states such as whether you are ready or whether a game is over.

Try it

Example · example.cpp
void small_main()
{
    bool is_ready = true;
    if (is_ready)
    {
        print("Start");
    }
    print(is_ready);
}

You can put a bool variable directly in if. Small's print displays true as 1 and false as 0. You can also store a comparison result, as in bool passed = score >= 60;.

Expected output:

Start
1

Exercise

Change is_ready to false and check how the output changes.

Exercise starter · exercise_starter.cpp
void small_main()
{
    bool is_ready = true;
    if (is_ready)
    {
        print("Start");
    }
    print(is_ready);
}

Hint

Change the parts of the example that you need.

show solution
void small_main()
{
    bool is_ready = false;
    if (is_ready)
    {
        print("Start");
    }
    print(is_ready);
}
← Previous lessonNext lesson →