June 2006
Intermediate to advanced
1344 pages
42h 52m
English
Let us present another complete example. We use nested repetition statements to solve the problem. Consider the following problem statement:
Write a program that draws in the command prompt a filled square consisting solely of one type of character, such as the asterisk (*). The side of the square and the character to be used to fill the square should be entered by the user. The length of the side should not exceed 20 characters. If the user enters a value over 20, the message “Side is too large” should be printed.
Your program should draw the square as follows:
Input the side of the square.
Validate that the side is less than or equal to 20.
Use repetition to draw the square by printing only one fill character ...
Read now
Unlock full access