Complete the code to start a while loop that runs as long as the variable count is less than 5.
int count = 0; while ([1]) { Console.WriteLine(count); count++; }
The while loop continues as long as the condition is true. To run while count is less than 5, use count < 5.
Complete the code to stop the while loop when number reaches 10.
int number = 0; while (number [1] 10) { Console.WriteLine(number); number++; }
The loop should run while number is less than 10, so the condition is number < 10.
Fix the error in the while loop condition to avoid an infinite loop.
int i = 0; while (i [1] 5) { Console.WriteLine(i); // Missing increment }
The condition should be i < 5 to run while i is less than 5. But the loop is missing i++ inside, which causes an infinite loop.
Fill both blanks to create a while loop that prints numbers from 1 to 5.
int num = 1; while (num [1] 5) { Console.WriteLine(num); num [2] 1; }
The loop runs while num <= 5 to include 5. The increment uses num += 1 to add 1 each time.
Fill all three blanks to create a while loop that prints even numbers from 2 to 10.
int val = [1]; while (val [2] 10) { Console.WriteLine(val); val [3] 2; }
Start at 2, run while val is less or equal to 10, and increase val by 2 each time to print even numbers.