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
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
Background image of page 1

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

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

This note was uploaded on 01/05/2012 for the course MATHEMATIC MA1505 taught by Professor Freudleong during the Spring '10 term at National University of Singapore.

Page1 / 4

tutorial05 - CS1010E Programming Methodology Semester 1...

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