ManualSum - cin >> n; cout...

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. .. // . 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 &gt;&gt; n; cout &lt;&lt; endl &lt;&lt; endl; c count = 0;// PLEASE COMPLETE THIS STATEMENT -- #1!! 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; } cout &lt;&lt; &quot;*** end of ManualSum ***&quot; &lt;&lt; endl &lt;&lt; endl; return 0; } // end of main...
View Full Document

This note was uploaded on 02/08/2011 for the course CSC 101 taught by Professor Joedzuback during the Spring '11 term at Union County.

Ask a homework question - tutors are online