Homework 2

# Homework 2 - int i = 0 cout<<"Enter a number"...

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

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;

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int i = 0; cout << "Enter a number: " ; cin >> side; sideCount = side; if (side < 0) return 0; do { j = 0; while (j <= i) { j++; cout << '#' ; } i++; cout << "\n" ; } while (i < side); } 5. switch (lec) { case 0: cout << "Unassigned" ; break ; case 1: cout << "Smelly" ; break ; case 2: cout << "Smelly" ; break ; case 3: cout << "Roar" ; break ; default : cout << "You're lost" ; break ; }...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

Homework 2 - int i = 0 cout<<"Enter a number"...

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

View Full Document
Ask a homework question - tutors are online