Write a program that reads in and sums the squares of positive integers until a value that 0 or less is read in.

What will be an ideal response?


```
// file ch2nu36.cc
// test question 36 for chapter 2
>>Delete above comment
#include
using namespace std;

//loop to accept positive integers until nonnegative
//integer, then return sum
int main()
{
int x = 1, i = 0, sum = 0;
cout << "Enter positive integers, followed by "
<< " 0 or negative stops." << endl
<< " I will give the sum." << endl;
while ( x > 0 )
{
cout << "Enter integer " << i << ": ";
cin >> x;
sum = sum + x;
i++;
}
cout << "sum: " << sum << endl;
return 0;
}
```

Computer Science & Information Technology

You might also like to view...

The _________ technique is used on a Windows server to optimize the use of threads.

A) ?polling ? B) ?asynchronous procedure call C) ?signaling an event object ? D) ?I/O completion ports

Computer Science & Information Technology

What does the following program do?

``` // Printing.cpp #include using namespace std; int main() { for (int i{1}; i <= 10; i++) { for (int j{1}; j <= 5; j++) { cout << '@'; } cout << endl; } } ```

Computer Science & Information Technology

This type of boot occurs when the computer is already on and you restart it without turning off the power.

A. cold boot B. warm boot C. generic boot D. live boot

Computer Science & Information Technology

To quit Word, click the Restore button on the right side of the title bar.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology