// Demonstration of sentinel while loops // // Written by: Angela Finlayson // Date: 14/09/2024 #include int main(void) { int number = 0; int end_loop = 0; // 1. Initialise the loop control variable while (end_loop == 0) { // 2. Test the loop condition scanf("%d", &number); if (number < 0) { // We want a negative value to end the loop end_loop = 1; // 3. Update the loop control variable } else { printf("You entered %d\n", number); } } return 0; }