Course of Raku / Essentials / Loops / Using while

Quiz — the while loop

1

What does this program print?

my $n = 10;
while $n {
    $n--;
}
say $n;
0Answer: (: 0, 1, −1 :)

2

How to prevent this program from running infinitely? Make the necessary changes to the code.

.my $n = 5;
.my $a = 10;
.while $n {
n a    say $␣--;
.}

Course navigation

Using while   |   Using until

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська