#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nNumberofArgs, char* pszArgs[]) { // The first, outer loop cout << "This program sums multiple series\n" << "of numbers. Terminate each sequence\n" << "by entering a negative number.\n" << "Terminate the series by entering \n" << "two negative numbers in a row.\n"; int accu; do { // start enterin the next sequence // of numbers accu = 0; cout << "Start the next sequence\n"; // loop forever for (;;) { // fetch another number int value = 0; cout << "Enter the next number: "; cin >> value; // if it's negative if (value < 0) { break; } // If not, add the number to accu accu = accu + value; } cout << "The total for this sequence is " << accu << endl; } while (accu != 0); cout << "Thank you!" << endl; system("PAUSE"); return 0; } |