CIS 71: Homework 4

Handed out: 09/19/2006
Due: by 10:00pm on 09/25/2006
Email program to TA

Write a program that prompts the user to enter a positive integer, say X, and then prints out a square centered on the line (which you can assume to be 80 columns wide).

Do the assignment by defining and using the function

     void drawSquare(int size);
The main program will just prompt the user to enter the size of the square and then call the drawSquare function.

Here is a sample run of your program [notice that rows look "bigger" than columns]:


Enter value for the side of the square: 30
                           XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           X                            X
                           XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
If the user enters a value less than one, a warning should be printed. If the user enters a value greter than 80, the program will act as if the user had entered 80.