//This is an example of very bad style... Let's see if we can clean it right up. //My insides are cringing at this code and I am getting an eye twitch - //what about you? //Sasha Vassar Week 3, Lecture 5 // 1. What do you think this program does? // 2. Can you see any mistakes? // 3. How do we fix *this*? #include #define SOMETHING 13 #define NEXT 5 int main (void){ int first_number; int second_number; int sum; int scanf_return; int counter = 0; char loop_control = 'y'; while (loop_control == 'y') { printf("Guess the first number: "); scanf_return = scanf("%d", &first_number); if (scanf_return != 1) { printf("Error, number not entered\n"); return 1; } printf("Guess the second number: "); scanf_return = scanf("%d", &second_number); if (scanf_return != 1) { return 1; } sum = first_number + second_number; if (sum != SOMETHING){ printf("The sum of the numbers you guess is either too small or too large.\n"); } else { printf("The sum of the numbers you guessed is the correct sum!\n"); } counter++; // counter++; //counter = counter - 1 same as counter--; printf("Would you like to try guessing again (y/n)? "); scanf(" %c", &loop_control); } printf("You had %d guesses before you guessed correctly\n", counter); return 0; }