{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

tutorial05 - CS1010E Programming Methodology Semester 1...

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

View Full Document Right Arrow Icon
CS1010E Programming Methodology Semester 1 2011/2012 Week of 26 – 30 September 2011 Tutorial 5 Problem Solving with Control Flow Statements 1. Just like how printing number sequences is the best way to test your understanding of looping constructs, printing patterns is another good way to test your understanding of nested loop constructs. (a) Write a function printLeftTriangle() that takes as argument an integer n and prints a left-sided triangle. For example, if n is 5, the following is printed * ** *** **** ***** (b) Write a function printRightTriangle() that takes as argument an integer n and prints a right-sided triangle. For example, if n is 5, the following is printed * ** *** **** ***** (c) Write a function printMiddleTriangle() that takes as argument an integer n and prints a right-sided triangle. For example, if n is 5, the following is printed * *** ***** ******* ********* (d) Write a function printHollowTriangle() that takes as argument an integer n and prints a right-sided triangle. For example, if n is 5, the following is printed * * * * * * * ********* You are encouraged to devise your own patterns and post in the IVLE forum.
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}