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.
You might also like to view...
What are the valid indexes for the array shown below?
int myArray[25]; a. 0-25 b. 0-24 c. 1-25 d. 1-24
Which of the following methods prints a list of the methods that were called before the exception was thrown?
A. getMessage() B. printCalledMethods() C. printStackTrace() D. traceMethodStack()
A(n) ________ can be used to display a visual representation of information and help effectively communicate ideas
Fill in the blank(s) with the appropriate word(s).
A petabyte is equal to approximately 1 billion bytes.
Answer the following statement true (T) or false (F)