// Demonstration of conditional while loops // // Written by: Angela Finlayson // Date: 14/09/2024 #include #define MAX_KOMBUCHA 2000 int main(void) { // 1. Initialise the loop control variable int total_kombucha_ml = 0; int kombucha_ml; // What happens if we get to exactly 2000ml? What // does the code do? Should we modify that? // 2. Test the loop condition while (total_kombucha_ml < MAX_KOMBUCHA) { printf("You have drunk %d/%dml" " of kombucha so far\n", total_kombucha_ml, MAX_KOMBUCHA); printf("Please enter the ml of kombucha: "); scanf("%d", &kombucha_ml); // 3. Update loop control variable total_kombucha_ml = total_kombucha_ml + kombucha_ml; } if(total_kombucha_ml == MAX_KOMBUCHA){ printf("Great but now you have had enough\n"); } else { printf("Stop! That would bring you to %dml!!\n", total_kombucha_ml); } return 0; }