ManualSum9b

# ManualSum9b - <<" is"<< sum<<...

This preview shows pages 1–2. Sign up to view the full content.

// file: ManualSum.cpp // author: j. dzuback // modified: // date: / /* ********************************************** The program prompts the user for an integer value n, and then finds the sum of the numbers from 0 to n. This variation of a summing loop has a few variations. .. ********************************************** */ #include <iostream> #include <iomanip> #include <string> # using namespace std; u int main() { int sum = 0; int n; int count; char letter; c cout << "Enter an integer (less than 20) and press return: "; cin >> n; cout << endl << endl; c count = 0;// PLEASE COMPLETE THIS STATEMENT -- #1!! c { int sum = 0; int count = 0; { sum = sum+count; count++; } // end of loop } cout <<"The sum of the numbers betweem 0 and " << n << " is " << sum << endl << endl; cout << "\nEnter an integer (less than 20) and press return: "; cin >> n; cout << endl << endl; } // end of loop cout << "Sum of the digits between 0 and " << n

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: << " is: " << sum << endl << endl; < cout<<"\nYou chose to terminate the program, to continue press 'y' if not press 'n': "; cin>>letter; switch(letter) { case 'y': cout << "Enter an integer (less than 20) and press return: "; cin >> n; cout << endl << endl; c while ((n >=0) && (n <= 20)) // if n is from 0 to 20 { int sum = 0; int count = 0; while ((count <= n) && (n<=20)) // do sum { sum = sum+count; count++; } // end of loop } cout <<"The sum of the numbers betweem 0 and " << n << " is " << sum << endl << endl; cout << "\nEnter an integer (less than 20) and press return: "; cin >> n; cout << endl << endl; } // end of loop cout << "Sum of the digits between 0 and " << n << " is: " << sum << endl << endl; break; b case 'n': cout << "*** end of ManualSum ***" << endl << endl; break; b default: cout << "*** end of ManualSum ***" << endl << endl; break; b } return 0; } // end of main...
View Full Document

### Page1 / 2

ManualSum9b - <<" is"<< sum<<...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online