Nested Loops

Rectangle Example:

Write a code fragment that prints a length by height rectangle of *'s. For example, if length is 20 and height is 10, it should print:

********************
********************
********************
******************** 
******************** 
******************** 
******************** 
******************** 
******************** 
********************


Triangle Example:

Write a code fragment that prints a length by length right triangle of *'s. For example, if length is 8, it should print:

*
** 
*** 
**** 
***** 
****** 
******* 
********


Diamond Example:

Write a code fragment that prints a diamond of *'s that is n wide at its widest. For example, if n is 10, it should print:

         * 
        * * 
       * * * 
      * * * * 
     * * * * * 
    * * * * * * 
   * * * * * * * 
  * * * * * * * * 
 * * * * * * * * * 
* * * * * * * * * * 
 * * * * * * * * * 
  * * * * * * * * 
   * * * * * * * 
    * * * * * * 
     * * * * * 
      * * * * 
       * * * 
        * * 
         *

Solutions