Question: The following program supposes to sum all entered int values that are greater than 5. It takes integer input and -1 indicates the end
The following program supposes to sum all entered int values that are greater than 5. It takes integer input and -1 indicates the end of input. It compiles without any error message, and it executes without error message, but nevertheless is wrong. What is wrong with the program? #include int main() { } int x, sum = 0; while (x!= -1) { } scanf("%d",&x); if (x > 5); sum sum +x; printf("The sum of values > 5 is %d ", sum); The semicolon at the end of the if statement causes all entered values to be summed. The semicolon at the end of the if statement is an error that the compiler should catch. The while loop does not terminate when input is -1. The while header needs a semicolon at the end of its line. Activate Windows Go to Settings to activate Wi
Step by Step Solution
3.48 Rating (158 Votes )
There are 3 Steps involved in it
The issue with the program is the misplaced closing brace for the while lo... View full answer
Get step-by-step solutions from verified subject matter experts
