YCP Logo Assignment 3: Log Cabin Pattern

Due: Tuesday, February 24th by 11:59 PM

Getting Started

Start by downloading CS101_Assign3.zip, saving it in the directory H:\CS101.

Start a Cygwin Bash Shell and run the following commands:

cd h:
cd CS101
unzip CS101_Assign3.zip
cd CS101_Assign3

Using Notepad++, open the file


You will add your code to this file.

Run the command


when you are ready to compile the program. To run the program, run the command


Your Task

Your task is to write a program that displays a Log Cabin Quilt Pattern. (Click on the link to see an example.)

You will use the same output functions that you used in Lab 7b. See the lab description for details. Note that your program should not use the printf function.

The LogCabin.cpp file will contain a main function. You will add code to the main function, but do not remove any of the statements that are already there.

The program should start by generating a random integer in the range 10 to 21. (Make sure your program uses the srand function to seed the random number generator, to ensure that different values are generated when the program is run multiple times.)

The random value generated is the height of the Log Cabin pattern to display. The top line of the output window should display a message indicating the height of the pattern being shown. The pattern should be centered (horizontally and vertically) in the output window. You may assume that the window will have 80 columns and 25 rows.

You may use whichever colors you prefer.

Example screenshots:




You can draw solid blocks of color by using cons_change_color to set the background to the color you want to draw, and then using cons_printw to print space characters.

In order to create an (approximately) square pattern, the pattern should have twice as many columns of characters than rows.

Grading Criteria

For a grade up to 70%: draw a "bulls-eye" pattern consisting of nested rectangles of different colors. The pattern does not need to be centered in the window. Example:


For a grade up to 80%: draw a "bulls-eye" pattern which is centered in the output window:


For a grade of up to 100%: draw the complete Log Cabin pattern as described above. The pattern must be centered, must be divided diagonally, and must use different pairs of colors in the two (diagonally-separated) halves.

Coding style: Make sure that you use meaningful variable names, that your code is properly indented, and that you include some comments explaining how the code works. Credit may be deducted if you use poor coding style.


To submit your work, make sure your LogCabin.cpp file is saved, and type the command

make submit

Enter your Marmoset username and password (which you should have received by email.) Note that your password will not be echoed to the screen. Make sure that after you enter your username and password, you see a message indicating that the submission was successful.

Important: Make sure that you check the file(s) you submitted to ensure that they are correct. Log into the server using the following URL:


You should see a list of labs and assignments. In the row for assign3, click the link labeled view. You will see a list of your submissions. Download the most recent one (which should be listed first). Verify that it contains the correct files.

You are responsible for making sure that your submission contains the correct file(s).