Complete the code to create a do-while loop that prints "Hello" once.
int main() {
int count = 0;
do {
std::cout << "Hello\n";
count++;
} while ([1]);
return 0;
}The condition count < 1 ensures the loop runs once and then stops.
Complete the code to keep asking the user for a number until they enter 0.
int main() {
int num;
do {
std::cout << "Enter a number (0 to stop): ";
std::cin >> num;
} while ([1]);
return 0;
}The loop continues while the number is not zero, so the condition is num != 0.
Fix the error in the do-while loop condition to repeat while x is less than 5.
int main() {
int x = 0;
do {
std::cout << x << " ";
x++;
} while (x [1] 5);
return 0;
}The loop should continue while x < 5 to print numbers 0 to 4.
Fill both blanks to create a do-while loop that prints numbers from 1 to 3.
int main() {
int i = 1;
do {
std::cout << i << " ";
i[1];
} while (i [2] 3);
return 0;
}Increment i with ++ and continue while i is less than or equal to 3.
Fill all three blanks to create a do-while loop that sums numbers from 1 to 5.
int main() {
int sum = 0;
int num = 1;
do {
sum [1] num;
num [2];
} while (num [3] 5);
std::cout << sum << std::endl;
return 0;
}Use sum += num; to add num to sum, increment num with ++, and continue while num is less than or equal to 5.