Classwork 24: nested for loops revisited

Objectives

more practice with nested for loops.

The Assignment


Write a program that asks the user for the length and height of a rectangle. Your program draws a rectangle of that size and a smaller rectangle inside it. The smaller rectangle has half the size of the larger rectangle. Sample runs of your program might look like:

PT[274]% ./a.out
Enter # of rows: 12
Enter length of each row: 12
 *  *  *  *  *  *  *  *  *  *  *  * 
 *                                * 
 *                                * 
 *        *  *  *  *  *  *        * 
 *        *              *        * 
 *        *              *        * 
 *        *              *        * 
 *        *              *        * 
 *        *  *  *  *  *  *        * 
 *                                * 
 *                                * 
 *  *  *  *  *  *  *  *  *  *  *  * 
PT[275]% 

PT[275]% ./a.out
Enter # of rows: 8
Enter length of each row: 16
 *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 
 *                                            * 
 *           *  *  *  *  *  *  *  *           * 
 *           *                    *           * 
 *           *                    *           * 
 *           *  *  *  *  *  *  *  *           * 
 *                                            * 
 *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 
PT[276]% ./a.out

The starting point of your program is: nested6.c.

Notes

Submit

Use the script command to record several sample runs of your program. Demonstrate that your program works for different size rectangles as well as non-square rectangles. Don't forget to exit from script. Then, submit your program and sample run as usual:

submit cs104_chang cw24 nested.c
submit cs104_chang cw24 typescript