Difference between revisions of "CSC231 Loop Exercises"

From dftwiki3
Jump to: navigation, search
(New page: Back to CSC231 Schedule ---- =Exercise 1= Review. Write a simple program that prints a line of 30 stars ****************************** =Exercise 2= Using a ...)
 
Line 1: Line 1:
[[CSC231_Class_Page | Back]] to CSC231 Schedule
+
--[[User:Thiebaut|D. Thiebaut]] 11:21, 20 October 2010 (UTC)
 
 
 
----
 
----
  
Line 33: Line 32:
  
 
Same exercise, but this time the first line printed contains 1 star, the next 2 stars, and so on until the last one, which contains 30 stars.
 
Same exercise, but this time the first line printed contains 1 star, the next 2 stars, and so on until the last one, which contains 30 stars.
 +
 +
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
[[Category:CSC231]][[Category:Exercises]]

Revision as of 06:21, 20 October 2010

--D. Thiebaut 11:21, 20 October 2010 (UTC)

Exercise 1

Review. Write a simple program that prints a line of 30 stars

******************************

Exercise 2

Using a loop, write a simple program that prints 30 lines of stars, such that the first line contains 30 stars, the next one 29 stars, then 28 stars, until the last line printed contains only 1 star.

******************************
*****************************
****************************
***************************
**************************
*************************
************************
***********************
**********************
*********************
.
.
.
***
**
*

Exercise 3

Same exercise, but this time the first line printed contains 1 star, the next 2 stars, and so on until the last one, which contains 30 stars.