Combine the statements into a program that calculates and prints the sum of the integers from 1 to 10. . Use the while statement to loop through the calculation and increment statements. The loop should terminate when the value of x becomes 11.
```
// Calculate.cpp
// Calculate the sum of the integers from 1 to 10
#include
using namespace std;
int main() {
unsigned int sum{0};
unsigned int x{1};
while (x <= 10) { // while x is less than or equal to 10
sum += x; // add x to sum
++x; // increment x
}
cout << "The sum is: " << sum << endl;
}
```
The sum is: 55
You might also like to view...
A data series is a group of related data points that are plotted in a chart
Indicate whether the statement is true or false
The ____________________ function removes array elements and other variables.
Fill in the blank(s) with the appropriate word(s).
The Bullets button is available on the Home tab of the Ribbon in the ____ group.
A. Special Characters B. Format C. Paragraph D. Options
Which of the following types of interactive media users contributes or authors content on the Web, such as posting a YouTube video or editing a Wikipedia article?
A. Passive Viewer B. Active User C. Participant D. Abstainer