do-while Loop
Executes the body at least once, then checks the condition.
c
#include <stdio.h>
int main() {
int choice;
do {
printf("
=== MENU ===
");
printf("1. Add
2. Subtract
3. Exit
");
printf("Enter choice: ");
scanf("%d", &choice);
if (choice == 1) printf("Add selected
");
else if (choice == 2) printf("Subtract selected
");
} while (choice != 3);
printf("Goodbye!
");
return 0;
}Key Difference while checks condition before loop. do-while checks after loop. Menu programs always use do-while because the menu must show at least once.