Lab 3 : Pattern Maker

June 24, 2020
Instructions:

The third lab will cover loops and conditionals.  Log in to your Zybooks account. If you haven't already signed up in zyBooks, see the course syllabus on how to do this. Open the third lab, found in section 4.29.   Edit and run your program in "Develop Mode", and then switch to "Submit Mode" when you want to run the official tests.



What you will Need to Do::

  • For this lab we will be designing a pattern maker (Section 4.29 of Zybooks).
HINT: Consider the use of while loops to give the output 1 2 3 4 5
    int i=1;
    while( i<=5) {
         cout << i << " ";
          i   ;
     }
and a for loop to give the same output:
    int i=1;
    for(i=1;i<=5;i ){
           cout << i << "  ";
     }
  • The pattern maker takes an odd number as user input and draws the required pattern as per the level of the designer.
  • Change the program in to take user Input for an odd number for the pattern maker.
  • The Code given to you allows you to choose the pattern to be printed.
Level 1: Square (1 Point)
The pattern maker takes an odd integer as an input and outputs a square pattern.
Use the odd integer to determine the side of a square.
For example:
          Welcome to Pattern maker. 
          Please an odd Integer for the Pattern Maker: 5
           *****
           *****
           *****
           *****
           *****


Level 2: Triangle (1 Point)
The triangle pattern maker takes an odd integer as an input and outputs a Triangle pattern.
Use the odd integer to determine the max length of the triangle. For example:
          Welcome to Pattern maker.
          Please an odd Integer for the Pattern Maker: 5
         
          *
          ***
          *****
Level 3: Diamond (Extra Credit, 1 Point)
The pattern maker takes an odd integer as an input and outputs a diamond pattern. Use the odd integer to determine the length of the diamond. For example:
         Welcome to Pattern maker.
         Please an odd Integer for the Pattern Maker: 5

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