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...
If the value of age is ____, the condition below produces a value of true.age > 12 && age < 20
A. 12 B. 13 C. 20 D. 25
Match the Microsoft Sway elements with their meaning:
I. Card II. Preview III. Sway command bar IV. All Cards pane A. An element that includes the type of content and commands and settings to work with the content. B. Contains commands to create and format a Sway. C. Displays buttons to insert different types of content into a Sway. D. Enables you to view the way a Sway looks and behaves.
A purpose of a citation is to:
A) identify the author of the research paper. B) direct a reader to a source of information. C) indicate the writing style used. D) identify a set of standards for developing a research paper.
The main factor affecting a program's readability is its ____.
A. layout B. spelling C. language D. development environment