O'Reilly logo
  • Ilija Injac thinks this is interesting:

#include <iostream>

using namespace std;

int main()
{
    int  sum = 0;
    int  n = 0;

    do {
        cout << "Enter a number (0 for exit): ";
        cin >> n;
        n += sum;
    } while (n > 0);
    cout << "The sum is " << sum <&l...

From

Cover of C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Third Edition

Note

There is a typo in this code. It should state sum +=n instead of n+=sum