5.12. Nested Repetition Statements

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:

  1. Input the side of the square.

  2. Validate that the side is less than or equal to 20.

  3. Use repetition to draw the square by printing only one fill character ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.