CIS071 Lab03 – Drawing Stick Figures DUE: (Noon, Tue, Feb 6)
PROBLEM
You
should write 3 programs:
john.c that draws stick figure of
John
mary.c that draws stick figure of
Mary
beldar.c that draws stick figure of Beldar
The
stick figures are presented below (observe that all figures consist of head,
body and legs).
* * *
* * * * * *
* * * * *
*
* * * *
* *
* * *********
********* * *
* * * * * *
* * * *
* *
* * *
* * *
********* ********* *
* * *
* * * * * *
* * * *
*
*
* * *
* * *
John Mary Beldar
INSTRUCTIONS
1. Make
a new directory (e.g. mkdir Lab03) and
include it in the default path (e.g. cd
Lab03).
2. Use pico
to create file john.c.
Write a program that displays the stick figure of John. The main function of
the program needs only consist of a number of printf calls.
For example, if you wanted to draw the following
figure:
*
* *
* *
the main function could look
like this:
printf(“ * \n”);
printf(“ * * \n”);
printf(“
* * \n”);
3.
Use the command: gcc john.c -o john to compile the
program and generate an executable file john.
4. Test this program to
be sure that it works correctly
5.
Write program mary.c
that displays the stick figure of Mary. In order to do this, you have two
choices:
A) create a new file mary.c and type
in the whole program from scratch
B) observe that john.c program
has many similarities with mary.c
Choice
B is better since it allows you to complete the task with less effort.
Therefore, you should use pico to modify program john.c and save it as mary.c.
6.
Recompile, test and correct mary.c program as often as necessary until it works
correctly.
7.
Write program beldar.c
by modifying mary.c
code.
8.
Recompile, test and correct beldar.c program as often as necessary until it works
correctly.
DELIVERABLES
Use
the “Pine” email facility to email the 3 programs to the TA. Subject of
your email should contain your name, course title, and lab number (for example:
Slobodan Vucetic, CIS071, Lab3) and attach files john.c, mary.c,
and beldar.c.
IMPORTANT
Be
sure to include documentation at the beginning of the programs, specifically:
Requirements: What is the program supposed to do?
Method: How will the program do it?
Test Plan: What are the tests to demonstrate that the program works
Your
programs should also contain several comments. For example, before writing a
sequence of prinf commands that display body of John
figure you could write a line that states
/* Drawing John’s body */