hw - ; cin >> side; int i = side; int...

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

View Full Document Right Arrow Icon
1. endlendl grendel 2. Prints out a triangle, with legs of length side, starting from top right expanding to bottom left. 3. #include <iostream> using namespace std; int main() { int side; cout << "Enter a number: " ; cin >> side; int j; for ( int i = side; i > 0; i--){ j = 0; while (j < i-1){ cout << " " ; j++; } while (j < side){ cout << "#" ; j++; } cout << endl; } } 4. #include <iostream> using namespace std; int main() { int side; cout << "Enter a number: "
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: ; cin &gt;&gt; side; int i = side; int j; do { if (i &gt; 0){ j = 0; while (j &lt; i-1){ cout &lt;&lt; &quot; &quot; ; j++; } while (j &lt; side){ cout &lt;&lt; &quot;#&quot; ; j++; } i--; cout &lt;&lt; endl; } } while (i &gt; 0); } 5. switch (week){ case 0: cout &lt;&lt; &quot;first lecture&quot; ; break ; case 4: case 7: cout &lt;&lt; &quot;midterm&quot; ; break ; case 10: cout &lt;&lt; &quot;final&quot; ; break ; default : cout &lt;&lt; &quot;nothing&quot; ; }...
View Full Document

This note was uploaded on 10/16/2011 for the course ECON 102 taught by Professor Staff during the Spring '08 term at UC Davis.

Page1 / 2

hw - ; cin &amp;amp;gt;&amp;amp;gt; side; int i = side; int...

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