Solutions to the exercises available
here.
1. |
* ** *** **** ***** **** *** ** * |
2. |
* * ** ** *** *** **** **** ********** **** **** *** *** ** ** * * |
3. |
* ******* * ** ***** ** *** *** *** **** * **** ***** ***** **** * **** *** *** *** ** ***** ** * ******* * |
4. |
** ** ** ** ** ** ** ** **** ** **** ** ** ** ** ** ** ** ** |
5. |
* ** *** ***** ******** ************* ********************* **********************************Hint: look at the difference in the lengths of consecutive lines |
6. |
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***For this question the user should be able to specify both the size of the small squares and the size of the large grid. |
7. |
*********** ***** ***** **** **** *** *** ** ** * * ** ** *** *** **** **** ***** ***** *********** |
8. |
************* ****** ****** ***** # **** **** ### **** *** ##### *** ** ####### ** * ######### * ** ####### ** *** ##### *** **** ### **** ***** # ***** ****** ***** ************* |
9. | Combine the patterns for questions 6 and 8, so that the output is a checkerboard pattern where each `black' square looks like the pattern from question 8. |
10. |
**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ******** ********The user should be able to specify the width of the ribbon as well as the height of the pattern. |
11. |
for (int i = 0; i < 101; i++) { // body } |
12. |
for (int i = 1; i < 101; i++) { // body } |
13. |
for (int i = 0; i <= 101; i++) { // body } |
14. |
for (int i = 0; i < 101; i += 2) { // body } |
15. |
for (int i = 1; i < 101; i += 2) { // body } |
16. |
for (int i = 0; i < x; i++) { // body } |
17. |
for (int i = x; i <= y; i += 2) { // body } |
18. |
for (int i = x; i > y; i -= z) { // body } |
19. |
for (int i = 42; i < 42; i += 3) { // body } |
20. |
for (int i = 0; i <= 1024; i *= 2) { // body } |
These notes were produced as part of the course Introduction to Programming as it was given in the Department of Computer Science at Queen Mary, University of London during the academic years 1998-2001.
Last modified: 30 September 1999