Homework 2

Homework 2 - int i = 0; cout <<...

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

View Full Document Right Arrow Icon
Homework 2 Written By: James Chung 703 591 869 1. endlendl grendel 2. It makes a pyramid/triangle shape of #, where the base is the number you put in, and the top is one #. 3. #include <iostream> using namespace std; int main() { int side; int j = 0; int sideCount; cout << "Enter a number: " ; cin >> side; sideCount = side; for ( int i = 0; i < side; i++) { j = 0; while (j <= i) { j++; cout << '#' ; } cout << "\n" ; } } 4. #include <iostream> using namespace std; int main() { int side; int j = 0; int sideCount;
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: int i = 0; cout &lt;&lt; &quot;Enter a number: &quot; ; cin &gt;&gt; side; sideCount = side; if (side &lt; 0) return 0; do { j = 0; while (j &lt;= i) { j++; cout &lt;&lt; '#' ; } i++; cout &lt;&lt; &quot;\n&quot; ; } while (i &lt; side); } 5. switch (lec) { case 0: cout &lt;&lt; &quot;Unassigned&quot; ; break ; case 1: cout &lt;&lt; &quot;Smelly&quot; ; break ; case 2: cout &lt;&lt; &quot;Smelly&quot; ; break ; case 3: cout &lt;&lt; &quot;Roar&quot; ; break ; default : cout &lt;&lt; &quot;You're lost&quot; ; break ; }...
View Full Document

Page1 / 2

Homework 2 - int i = 0; cout &amp;amp;lt;&amp;amp;lt;...

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