Complete the code to create a while loop that prints numbers from 1 to 3.
$i = 1 while ($i [1] 4) { Write-Output $i $i++ }
The -lt operator means 'less than'. The loop runs while $i is less than 4.
Complete the code to create a do-while loop that prints numbers from 1 to 3.
$i = 1 do { Write-Output $i $i++ } while ($i [1] 4)
The loop runs while $i is less than 4, so it prints 1, 2, and 3.
Fix the error in the while loop condition to count down from 5 to 1.
$i = 5 while ($i [1] 0) { Write-Output $i $i-- }
The loop should run while $i is greater than 0 to count down from 5 to 1.
Fill both blanks to create a while loop that prints even numbers from 2 to 10.
$i = 2 while ($i [1] 10) { Write-Output $i $i [2] 2 }
The loop runs while $i is less than or equal to 10, and increments $i by 2 each time.
Fill all three blanks to create a do-while loop that prints numbers from 10 down to 1.
$i = [1] do { Write-Output $i $i [2] 1 } while ($i [3] 0)
Start $i at 10, subtract 1 each time, and continue while $i is greater than 0.