(Summing Integers) Write a program that uses a for statement to sum a sequence of inte- gers. Assume that the first integer read specifies the number of values remaining to be entered. Your program should read only one value per input statement. A typical input sequence might be 5 100 200 300 400 500 where the 5 indicates that the subsequent 5 values are to be summed.

What will be an ideal response?


```
// Total a sequence of integers.
#include
using namespace std;

int main()
{
int total = 0; // current total
int number; // number of values
int value; // current value

// display prompt
cout << "Enter the number of values to be summed "
<< "followed by the values: \n";
cin >> number; // input number of values

// loop number times
for ( int i = 1; i <= number; i++ )
{
cin >> value;
total += value;
} // end for

// display total
cout << "Sum of the " << number << " values is " << total << endl;
} // end main
```

Computer Science & Information Technology

You might also like to view...

What are some of the automated deployment options available in Windows 10?

What will be an ideal response?

Computer Science & Information Technology

In OneNote, names of ________ are automatically created when you type the title on the page

Fill in the blank(s) with correct word

Computer Science & Information Technology

On the Resource Sheet, resources in ____ are overallocated.

A. red B. black C. grey D. green

Computer Science & Information Technology

In the decimal system, _________ is the maximum value that a position can hold before it flips over into the next higher position.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology