The following program purports to sum all entered int values that are greater than 5. It compiles without any error message, and it executes without error message, but nevertheless is wrong. Name all the errors.
```
// Display the sum of all entered int values
// greater than 5
#include
int main()
{
using namespace std;
int x, sum;
while (x < 10)
{
cin >> x;
if (x > 5);
sum = sum +x;
}
cout << “The sum is values > 5 is “ << sum << endl;
```
a) The while header needs a semicolon at the end of its line.
b) The semicolon at the end of the if statement is an error that the compiler should
catch.
c) The semicolon at the end of the if statement causes all entered values to be
summed.
d) The sum variable is not initialized, so the output value is most likely garbage.
c) and d) are the errors. (Perhaps the user should have been prompted.)
You might also like to view...
When using Different First Page to format headers and footers under one section in the middle of a document, which is NOT one of the given options?
A) Last Page Header B) Header C) First Page Footer D) First Page Header
Which VTP mode does not allow the CLI configuration of VLANs?
A) Client B) Off C) Server D) Transparent