ManualSum9b - << " is:...

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

View Full Document Right Arrow Icon
// 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

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

Page1 / 2

ManualSum9b - &amp;amp;lt;&amp;amp;lt; &amp;amp;quot; is:...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online