{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ManualSum - cin>> n cout<< endl<< endl c count...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// filename: ManualSum.cpp // author: j. dzuback // modified: // date: 09/30/09 / /* ********************************************** 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 n; int count; int sum = 0; i // consider the elements of the loop. .. // . ..as you "fill in the blanks" below / cout << "Enter an integer (less than 20) and press return: ";
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cin >> n; cout << endl << endl; c count = 0;// PLEASE COMPLETE THIS STATEMENT -- #1!! 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; } cout << "*** end of ManualSum ***" << endl << endl; return 0; } // end of main...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online