Introduction to Programming - CS201 Spring 2003 Assignment 03

By    


Challenging Question

 

Deadline


Your Challenge Code must be uploaded/submitted at or before 18th March 2003

Objective


The objective of this Challenge Question is for the students to:

o                   Produce the most efficient code
o                   Enhance Analysis skill and devise better logic
o                   Practice of Nested Loops

    

Challenge Question


Write a small C program that prints the following shape patterns according to the user choice.

                                       Shapes

                                        
     *                             ******                        ******                          *       
     **                           *****                            *****                        **
     ***                         ****                                ****                      ***       
     ****                       ***                                    ***                    ****
     *****                     **                                        **                  *****
     ******                   *                                            *                ******
         (1)                       (2)                                      (3)                     (4)           

Your program should.

§         Prompts the user to select the shape.
§         Prompts the user to select the number of lines.
§         Display the shape according to the input given by the user.


Here’s a sample output

Press ‘A’ or ‘a’ for shape 1
Press ‘B’ or ‘b’ for shape 2
Press ‘C’ or ‘c’ for shape 3
Press ‘D’ or ‘d’ for shape 4

     Enter Your Choice:     A

     Enter the number of lines:     10


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

Challenge


·        Minimum repetitions in loops.

Note:
 Make the variable names self–explanatory,  Commenting the code properly and Indent your code properly for making it more understandable