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 of
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); }
options:
| The while header needs a semicolon at the end of its line. |
| The semicolon at the end of the if statement is an error that the compiler should catch. |
| The semicolon at the end of the if statement causes all entered values to be summed. |
| The while loop does not terminate when input is -1. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
