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;
}
```
You might also like to view...
The Center button on the HOME tab centers the text ________ in the cell
Fill in the blank(s) with correct word
The class Exception and its subclasses are designed to catch exceptions that should be caught and processed during program execution.
Answer the following statement true (T) or false (F)