Complete the code to print numbers from 1 to 3 using a do–while loop.
int i = 1; do { printf("%d\n", i); i[1]; } while (i <= 3);
The operator ++ increases i by 1 each time, allowing the loop to count from 1 to 3.
Complete the code to ensure the loop runs at least once and stops when count is 5.
int count = 0; do { printf("Count: %d\n", count); count++; } while ([1] < 5);
count++ or ++count in the condition changes the variable unexpectedly.count-- decreases the value, causing wrong loop behavior.The condition count < 5 checks the current value of count to decide if the loop should continue.
Fix the error in the do–while loop condition to avoid an infinite loop.
int n = 10; do { printf("%d\n", n); n--; } while (n [1] 0);
The loop should continue while n is greater than 0 to count down properly.
Fill both blanks to create a do–while loop that prints even numbers from 2 to 8.
int num = 2; do { printf("%d\n", num); num [1] 2; } while (num [2] 8);
Use num += 2 to increase by 2 each time, and num <= 8 to stop after printing 8.
Fill all three blanks to create a do–while loop that prints numbers from 5 down to 1.
int val = [1]; do { printf("%d\n", val); val [2] 1; } while (val [3] 1);
Start val at 5, decrease it by 1 each loop with -=, and continue while val >= 1.