// Modify this code to calculate the sum of all integers entered // by the user // The loop should end when the user enters non-integer data // // Written by: Angela Finlayson // Date: 14/09/2024 #include int main(void) { int valid_int; int sum = 0; int number = 0; int end_loop = 0; // 1. Initialise the loop control variable while (end_loop == 0) { // 2. Test the loop condition valid_int = scanf("%d", &number); if (valid_int != 1) { // 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); sum = sum + number; } } printf("Sum was %d\n", sum); return 0; }