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...
A column in one table that references a primary key in another table is known as a __________.
a. secondary keyy b. foreign key c. referential ke d. meta key
What happens if the coordinates of your tags in an image map overlap?
A. the first tag is used B. the last tag is used C. the tag used is selected arbitrarily D. the overlapping tags are ignored
Digital ____ authenticate the cryptographic key that is embedded in the certificate.
A. logs B. hashes C. certificates D. signatures
To access the Font Families tab shown in the figure above, you would click ____ .
A. Tools on the menu bar, and then Page Editor Options B. Tools on the menu bar, and then Font Family Options C. Format on the menu bar, and then Page Editor Options D. Format on the menu bar, and then Font Family Options