CS2134_HW4

# CS2134_HW4 - HOMEWORK#4 CS2134 Fall 2007 Due 11:59 p.m...

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

HOMEWORK #4 CS2134, Fall 2007 Due 11:59 p.m. Monday 10/29 Instructions: Submit the programming part in a single file called hw04.cpp. Submit the written part in a single file called hw04written.xxx, where xxx indicates the file format. The program for the programming part is short, but you will need to think before writing. Make sure to leave enough time to do the written part -- it is longer than usual. Programming Part: Consider the following triangle (we will call this an upside-down triangle): *************** ************* *********** ********* ******* ***** *** * Observation: If I remove the first row, the remainder is also a triangle of the same shape, except that its height is reduced by one, and it is indented one position. ************* *********** ********* ******* ***** *** * Using the above observation, write a recursive function print_up_tri(int i, int n) that prints an upside down triangle with n rows, indented by i positions. (How many asterisks should be in the top row?) For example, print_up_tri(2, 6) should print the triangle *********** ********* ******* ***** *** * Your function may contain a loop to print the asterisks in the top row of the upside-down triangle. The remaining rows of the triangle must be printed

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

View Full Document
by making a recursive call.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern