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) The semicolon at the end of the if statement causes all entered values to be summed., and d) The sum variable is not initialized, so the output value is most likely garbage.

Computer Science & Information Technology

You might also like to view...

A ________ control is an unbound control

A) combo box B) text box C) label D) tab order

Computer Science & Information Technology

Inkjet printers frequently have a built-in _______ cleaning routine to clean the inkjet cartridge

Fill in the blank(s) with correct word

Computer Science & Information Technology